@@ -66,7 +66,7 @@ static void racingCancel(CNSocket* sock, CNPacketData* data) {
6666 INITSTRUCT (sP_FE2CL_REP_EP_RACE_CANCEL_SUCC , resp);
6767 sock->sendPacket (resp, P_FE2CL_REP_EP_RACE_CANCEL_SUCC);
6868
69- /*
69+ /*
7070 * This request packet is used for both cancelling the race via the
7171 * NPC at the start, *and* failing the race by running out of time.
7272 * If the latter is to happen, the client disables movement until it
@@ -99,31 +99,37 @@ static void racingEnd(CNSocket* sock, CNPacketData* data) {
9999 if (EPData.find (mapNum) == EPData.end () || EPData[mapNum].EPID == 0 )
100100 return ; // IZ not found
101101
102+ EPInfo& epInfo = EPData[mapNum];
103+ EPRace& epRace = EPRaces[sock];
104+
102105 uint64_t now = getTime () / 1000 ;
106+ int timeDiff = now - epRace.startTime ;
107+ int podsCollected = epRace.collectedRings .size ();
103108
104- int timeDiff = now - EPRaces[sock].startTime ;
105- int score = 500 * EPRaces[sock].collectedRings .size () - 10 * timeDiff;
106- if (score < 0 ) score = 0 ; // lol
107- int fm = score * plr->level * (1 .0f / 36 ) * 0 .3f ;
109+ int score = std::min (epInfo.maxScore , (int )std::exp (
110+ (epInfo.podFactor * podsCollected) / epInfo.maxPods
111+ - (epInfo.timeFactor * timeDiff) / epInfo.maxTime
112+ + epInfo.scaleFactor ));
113+ int fm = (1.0 + std::exp (epInfo.scaleFactor - 1.0 ) * epInfo.podFactor * podsCollected) / epInfo.maxPods ;
108114
109115 // we submit the ranking first...
110116 Database::RaceRanking postRanking = {};
111- postRanking.EPID = EPData[mapNum] .EPID ;
117+ postRanking.EPID = epInfo .EPID ;
112118 postRanking.PlayerID = plr->iID ;
113- postRanking.RingCount = EPRaces[sock]. collectedRings . size () ;
119+ postRanking.RingCount = podsCollected ;
114120 postRanking.Score = score;
115121 postRanking.Time = timeDiff;
116122 postRanking.Timestamp = getTimestamp ();
117123 Database::postRaceRanking (postRanking);
118124
119125 // ...then we get the top ranking, which may or may not be what we just submitted
120- Database::RaceRanking topRankingPlayer = Database::getTopRaceRanking (EPData[mapNum] .EPID , plr->iID );
126+ Database::RaceRanking topRankingPlayer = Database::getTopRaceRanking (epInfo .EPID , plr->iID );
121127
122128 INITSTRUCT (sP_FE2CL_REP_EP_RACE_END_SUCC , resp);
123129
124130 // get rank scores and rewards
125- std::vector<int >* rankScores = &EPRewards[EPData[mapNum] .EPID ].first ;
126- std::vector<int >* rankRewards = &EPRewards[EPData[mapNum] .EPID ].second ;
131+ std::vector<int >* rankScores = &EPRewards[epInfo .EPID ].first ;
132+ std::vector<int >* rankRewards = &EPRewards[epInfo .EPID ].second ;
127133
128134 // top ranking
129135 int topRank = 0 ;
0 commit comments