Enemy Territory

Project: Bug Fix

The objective

The goal of this project is to provide modders in the ET community with a SDK code base that contains fixes for various bugs which are present in the stock etmain game (version 2.60).

26th september 2006: Sadly bugfix 088 had a bug :-( There were 3 lines that should have been deleted for the fix to work correctly.

Show index
Previous bug: Persistent score doesn't get updated if there hasn't happened anything in the map
Next bug: Respawn timer is shown while spectating

Bugfix 017 - Endgame awards and medals get handed out to the player with the highest XP in the different fields

Problem:

The awards and medals given out at intermission were given to the players who had the highest XP in the different fields, and not the players who had the highest XP increase in the different fields.

Solution:

One of the main problems for the awards was that the start xp number, never got reset. Also it would give out awards like the 'highest fragger' without any kills, or 'highest accuracy' without any accuracy.

Notes:

The bug is still present in version 2.60

2.56 & 2.60 Code

g_main.c @ 2460 (2.56) @ 2601 (2.60) int winner; int highestskillpoints, highestskillpointsclient, j, teamNum;
int highestskillpointsincrease; // CHRUKER: b017 - Preventing medals from being handed out left and right
trap_GetConfigstring( CS_MULTI_MAPWINNER, cs, sizeof(cs) );
g_main.c @ 2493 (2.56) @ 2624 (2.60) // award medals for( teamNum = TEAM_AXIS; teamNum <= TEAM_ALLIES; teamNum++ ) { for( i = 0; i < SK_NUM_SKILLS; i++ ) { highestskillpoints = 0;
highestskillpointsincrease = 0; // CHRUKER: b017 - Preventing medals from being handed out left and right
highestskillpointsclient = -1; for( j = 0; j < level.numConnectedClients; j++ ) { cl = &level.clients[level.sortedClients[j]]; if( cl->sess.sessionTeam != teamNum ) continue;
// CHRUKER: b017 - Make sure the player got some skills if( cl->sess.skill[i] < 1 ) continue; // CHRUKER: b017 - Only battlesense and light weapons medals are awarded to the highest score // Class medals get awarded to best ones. if ( i == SK_BATTLE_SENSE || i == SK_LIGHT_WEAPONS ) {
if( cl->sess.skillpoints[i] > highestskillpoints ) { highestskillpoints = cl->sess.skillpoints[i]; highestskillpointsclient = j; }
} else { if( (cl->sess.skillpoints[i] - cl->sess.startskillpoints[i]) > highestskillpointsincrease ) { highestskillpointsincrease = (cl->sess.skillpoints[i] - cl->sess.startskillpoints[i]); highestskillpointsclient = j; } } // b017
} if( highestskillpointsclient >= 0 ) { // highestskillpointsclient is the first client that has this highest // score. See if there are more clients with this same score. If so, // give them medals too for( j = highestskillpointsclient; j < level.numConnectedClients; j++ ) { cl = &level.clients[level.sortedClients[j]]; if( cl->sess.sessionTeam != teamNum ) continue;
// CHRUKER: b017 - Make sure the player got some skills if( cl->sess.skill[i] < 1 ) continue; // CHRUKER: b017 - Only battlesense and light weapons medals are awarded to the highest score // Class medals get awarded to best ones. if ( i == SK_BATTLE_SENSE || i == SK_LIGHT_WEAPONS ) {
if( cl->sess.skillpoints[i] == highestskillpoints ) { cl->sess.medals[i]++; ClientUserinfoChanged( level.sortedClients[j] ); }
} else { if( (cl->sess.skillpoints[i] - cl->sess.startskillpoints[i]) == highestskillpointsincrease ) { cl->sess.medals[i]++; ClientUserinfoChanged( level.sortedClients[j] ); } } // b017
} } } } } else if( g_gametype.integer == GT_WOLF_LMS ) {
g_session.c @ 330 (2.56) @ 306 (2.60) memset( sess->skill, 0, sizeof(sess->skill) ); memset( sess->skillpoints, 0, sizeof(sess->skillpoints) );
memset( sess->startskillpoints, 0, sizeof(sess->startskillpoints) ); // CHRUKER: b017 - startskillpoints didn't get reset
memset( sess->medals, 0, sizeof(sess->medals) ); sess->rank = 0;
sess->startxptotal = 0; // CHRUKER: b017 - startxptotal didn't get reset
// OSP
g_stats.c @ 567 (2.56) @ 582 (2.60) }
// CHRUKER: b017 - Added a check to make sure that the best result is larger than 0
#define CHECKSTAT1( XX ) \ best = NULL; \ for( i = 0; i < level.numConnectedClients; i++ ) { \ gclient_t* cl = &level.clients[ level.sortedClients[ i ] ]; \ if( cl->sess.sessionTeam == TEAM_SPECTATOR ) { \ continue; \ } \
if( cl->XX <= 0 ) { \ continue; \ } \
if( !best || cl->XX > best->XX ) { \ best = cl; \
g_stats.c @ 595 (2.56) @ 614 (2.60) Q_strcat( buffer, 1024, va( ";%s; %i ", best && best->XX >= YY ? best->pers.netname : "", best && best->XX >= YY ? best->sess.sessionTeam : -1 ) )
// CHRUKER: b017 - Moved the minimum skill requirement into a seperate if sentence // Added a check to make sure only people who have increased their skills are considered
#define CHECKSTATSKILL( XX ) \ best = NULL; \ for( i = 0; i < level.numConnectedClients; i++ ) { \ gclient_t* cl = &level.clients[ level.sortedClients[ i ] ]; \ if( cl->sess.sessionTeam == TEAM_SPECTATOR ) { \ continue; \ } \
if ((cl->sess.skillpoints[XX] - cl->sess.startskillpoints[XX]) <= 0) { \ continue; \ } \ if( cl->sess.skill[XX] < 1 ) { \ continue; \ } \
if( !best || (cl->sess.skillpoints[XX] - cl->sess.startskillpoints[XX]) > (best->sess.skillpoints[XX] - best->sess.startskillpoints[XX]) ) { \ best = cl; \ } \ } \ if( best ) { best->hasaward = qtrue; } \ Q_strcat( buffer, 1024, va( ";%s; %i ", best && best->sess.skillpoints[XX] >= 20 ? best->pers.netname : "", best && best->sess.skillpoints[XX] >= 20 ? best->sess.sessionTeam : -1 ) ) #define CHECKSTAT3( XX, YY, ZZ ) \

Show index
Previous bug: Persistent score doesn't get updated if there hasn't happened anything in the map
Next bug: Respawn timer is shown while spectating

Color coding

Sample = New code
Sample = Changed code (the new version is what is displayed)
Sample = Deleted code

©2017 Chruker