diff options
Diffstat (limited to 'src/game/g_cmds.c')
-rw-r--r-- | src/game/g_cmds.c | 81 |
1 files changed, 50 insertions, 31 deletions
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 17db035..eac9ac4 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -5117,7 +5117,8 @@ static void Cmd_Ignore_f( gentity_t *ent ) */ void Cmd_Share_f( gentity_t *ent ) { - int i, clientNum = 0, creds = 0, skipargs = 0; + int i, clientNum = 0, skipargs = 0; + float creds = 0.0f; int clientNums[ MAX_CLIENTS ] = { -1 }; char cmd[ 12 ]; char arg1[ MAX_STRING_TOKENS ]; @@ -5252,11 +5253,11 @@ static void Cmd_Ignore_f( gentity_t *ent ) } // credit count from parameter - creds = atoi( arg2 ); + creds = G_RoundFunds( atof( arg2 ), team ); } // player specified "0" to transfer - if( creds <= 0 ) + if( creds <= 0.0f ) { trap_SendServerCommand( ent-g_entities, "print \"Ooh, you are a generous one, indeed!\n\"" ); @@ -5270,7 +5271,7 @@ static void Cmd_Ignore_f( gentity_t *ent ) } // player has no credits - if( creds <= 0 ) + if( creds <= 0.0f ) { trap_SendServerCommand( ent-g_entities, "print \"Earn some first, lazy gal!\n\"" ); @@ -5290,7 +5291,7 @@ static void Cmd_Ignore_f( gentity_t *ent ) } // target cannot take any more credits - if( creds <= 0 ) + if( creds <= 0.0f ) { trap_SendServerCommand( ent-g_entities, va( "print \"share: player cannot receive any more %s.\n\"", @@ -5300,17 +5301,28 @@ static void Cmd_Ignore_f( gentity_t *ent ) // transfer credits G_AddFundsToClient( ent->client, -creds, qfalse ); - trap_SendServerCommand( ent-g_entities, - va( "print \"share: transferred %d %s to %s^7.\n\"", creds, - ( team == PTE_HUMANS ) ? "credits" : "evolvepoints", - level.clients[ clientNum ].pers.netname ) ); - G_AddFundsToClient( &(level.clients[ clientNum ]), creds, qtrue ); - trap_SendServerCommand( clientNum, - va( "print \"You have received %d %s from %s^7.\n\"", creds, - ( team == PTE_HUMANS ) ? "credits" : "evolvepoints", - ent->client->pers.netname ) ); + G_AddFundsToClient( level.clients + clientNum, creds, qtrue ); + + if (team == PTE_ALIENS) + { + trap_SendServerCommand( ent-g_entities, + va( "print \"share: transferred %.2f evolvepoints to %s^7.\n\"", creds, + level.clients[ clientNum ].pers.netname ) ); + trap_SendServerCommand( clientNum, + va( "print \"You have received %.2f evolvepoints from %s^7.\n\"", creds, + ent->client->pers.netname ) ); + } + else + { + trap_SendServerCommand( ent-g_entities, + va( "print \"share: transferred %.0f credits to %s^7.\n\"", creds, + level.clients[ clientNum ].pers.netname ) ); + trap_SendServerCommand( clientNum, + va( "print \"You have received %.0f credits from %s^7.\n\"", creds, + ent->client->pers.netname ) ); + } - G_LogPrintf( "Share: %i %i %i %d: %s^7 transferred %d%s to %s^7\n", + G_LogPrintf( "Share: %i %i %i %d: %s^7 transferred %f%s to %s^7\n", ent->client->ps.clientNum, clientNum, team, @@ -5330,8 +5342,8 @@ static void Cmd_Ignore_f( gentity_t *ent ) */ void Cmd_Donate_f( gentity_t *ent ) { char s[ MAX_TOKEN_CHARS ] = "", *type = "evo(s)"; - int i, value, divisor, portion, new_credits, total=0, - max = ALIEN_MAX_KILLS, *amounts; + int i, divisor, max = ALIEN_MAX_KILLS; + float value, total = 0.0f, amounts[ MAX_CLIENTS ] = {0.0f}; qboolean donated = qtrue; if( !ent->client ) return; @@ -5369,7 +5381,7 @@ static void Cmd_Ignore_f( gentity_t *ent ) } trap_Argv( 1, s, sizeof( s ) ); - value = atoi(s); + value = G_RoundFunds(atof(s), ent->client->pers.teamSelection); if( value <= 0 ) { trap_SendServerCommand( ent-g_entities, "print \"donate: very funny\n\"" ); @@ -5377,14 +5389,13 @@ static void Cmd_Ignore_f( gentity_t *ent ) } if( value > ent->client->pers.funds) value = ent->client->pers.funds; - - // allocate memory for distribution amounts - amounts = G_Alloc( level.maxclients * sizeof( int ) ); - for( i = 0; i < level.maxclients; i++ ) amounts[ i ] = 0; + // determine donation amounts for each client total = value; while( donated && value ) { + float portion, new_credits; + donated = qfalse; portion = value / divisor; if( portion < 1 ) portion = 1; @@ -5412,16 +5423,24 @@ static void Cmd_Ignore_f( gentity_t *ent ) G_AddFundsToClient( ent->client, value - total, qtrue ); for( i = 0; i < level.maxclients; i++ ) if( amounts[ i ] ) { - trap_SendServerCommand( i, - va( "print \"%s^7 donated %d %s to you, don't forget to say 'thank you'!\n\"", - ent->client->pers.netname, amounts[ i ], type ) ); + if( ent->client->pers.teamSelection == PTE_ALIENS) + trap_SendServerCommand( i, + va( "print \"%s^7 donated %.3f %s to you, don't forget to say 'thank you'!\n\"", + ent->client->pers.netname, amounts[ i ], type ) ); + else + trap_SendServerCommand( i, + va( "print \"%s^7 donated %.0f %s to you, don't forget to say 'thank you'!\n\"", + ent->client->pers.netname, amounts[ i ], type ) ); } - - G_Free( amounts ); - - trap_SendServerCommand( ent-g_entities, - va( "print \"Donated %d %s to the cause.\n\"", - total-value, type ) ); + + if( ent->client->pers.teamSelection == PTE_ALIENS) + trap_SendServerCommand( ent-g_entities, + va( "print \"Donated %.3f %s to the cause.\n\"", + total-value, type ) ); + else + trap_SendServerCommand( ent-g_entities, + va( "print \"Donated %.0f %s to the cause.\n\"", + total-value, type ) ); } |