EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Development: Custom Code (https://www.eqemulator.org/forums/forumdisplay.php?f=665)
-   -   Fix for leveling past level 86 (https://www.eqemulator.org/forums/showthread.php?t=42229)

phate8908 12-28-2018 11:14 PM

Fix for leveling past level 86
 
there is currently a bug where if your character is past level 86 and gains exp then it will automaticly be reset back to 86. reason for this is a buffer overflow on the pull of character data from your database to the zone client
this little patch is ment to fix this

with a lot of testing i was able to reach the 112 without having buffer overflow issues, currently live is at 110 so, i see no real need to raise level beyond that

Converts UINT32 -> char array to be readable
Code:

@@ -475,10 +475,16 @@ const char *ConvertArray(int input, char *returnchar)
 {
        sprintf(returnchar, "%i", input);
        return returnchar;
 }
 
+const char *ConvertArrayU(uint32 input, char *returnchar)
+{
+        sprintf(returnchar, "%u", input);
+        return returnchar;
+}
+
 const char *ConvertArrayF(float input, char *returnchar)
 {
        sprintf(returnchar, "%0.2f", input);
        return returnchar;
 }
@@ -491,6 +497,6 @@ bool isAlphaNumeric(const char *text)
                        (text[charIndex] < '0' || text[charIndex] > '9'))
                        return false;
        }
 
        return true;
-}
\ No newline at end of file
+}

this is only seeable by gms when they gain experience as a gm... so its not really needed unless your having issues and want to debug things
Code:

@@ -46,10 +46,11 @@ bool isAlphaNumeric(const char *text);
 bool strn0cpyt(char* dest, const char* source, uint32 size);
 char *CleanMobName(const char *in, char *out);
 char *RemoveApostrophes(const char *s);
 char* strn0cpy(char* dest, const char* source, uint32 size);
 const char *ConvertArray(int input, char *returnchar);
+const char *ConvertArrayU(uint32 input, char *returnchar);
 const char *ConvertArrayF(float input, char *returnchar);
 const char *MakeLowerString(const char *source);
 int MakeAnyLenString(char** ret, const char* format, ...);
 uint32 AppendAnyLenString(char** ret, uint32* bufsize, uint32* strlen, const char* format, ...);
 uint32 hextoi(const char* num);

This is mostly a sanity check, if the add_exp float for some reason does buffer over flow, lets not allow it to buffer overflow the character and send it back to level 1
Code:

@@ -443,11 +443,11 @@ void Client::CalculateExp(uint32 in_add_exp, uint32 &add_exp, uint32 &add_aaxp,
                if (zone->IsHotzone())
                {
                        totalmod += RuleR(Zone, HotZoneBonus);
                }
 
-                add_exp = uint32(float(add_exp) * totalmod * zemmod);
+                if (float(add_exp) >= 0.0f) add_exp = uint32(float(add_exp) * totalmod * zemmod);
 
                //if XP scaling is based on the con of a monster, do that now.
                if (RuleB(Character, UseXPConScaling))
                {
                        if (conlevel != 0xFF && !resexp)
@@ -756,11 +756,11 @@ void Client::SetEXP(uint32 set_exp, uint32 set_aaxp, bool isrezzexp) {
 
        if (admin>=100 && GetGM()) {
                char val1[20]={0};
                char val2[20]={0};
                char val3[20]={0};
-                Message_StringID(MT_Experience, GM_GAINXP, ConvertArray(set_aaxp,val1),ConvertArray(set_exp,val2),ConvertArray(GetEXPForLevel(GetLevel()+1),val3));        //[GM] You have gained %1 AXP and %2 EXP (%3).
+                Message_StringID(MT_Experience, GM_GAINXP, ConvertArrayU(set_aaxp, val1), ConvertArrayU(set_exp, val2), ConvertArray(GetEXPForLevel(GetLevel() + 1), val3));        //[GM] You have gained %1 AXP and %2 EXP (%3).
        }
 }
 
 void Client::SetLevel(uint8 set_level, bool command)
 {

this is the currently broken pull from the database that is normally only converted to a int, we are changing it to be converted into a long long, it being a long long will allow it to be converted to a UINT32 without any data loss
Code:

@@ -1114,11 +1114,11 @@ bool ZoneDatabase::LoadCharacterData(uint32 character_id, PlayerProfile_Struct*
                pp->ability_number = atoi(row[r]); r++;                                                                        // "ability_number,            "
                pp->ability_time_minutes = atoi(row[r]); r++;                                                        // "ability_time_minutes,      "
                pp->ability_time_hours = atoi(row[r]); r++;                                                                // "ability_time_hours,        "
                strcpy(pp->title, row[r]); r++;                                                                                        // "title,                    "
                strcpy(pp->suffix, row[r]); r++;                                                                                // "suffix,                    "
-                pp->exp = atoi(row[r]); r++;                                                                                        // "exp,                      "
+                pp->exp = atoll(row[r]); r++;                                                                                        // "exp,                      "
                pp->points = atoi(row[r]); r++;                                                                                        // "points,                    "
                pp->mana = atoi(row[r]); r++;                                                                                        // "mana,                      "
                pp->cur_hp = atoi(row[r]); r++;                                                                                        // "cur_hp,                    "
                pp->STR = atoi(row[r]); r++;                                                                                        // "str,                      "
                pp->STA = atoi(row[r]); r++;                                                                                        // "sta,                      "



All times are GMT -4. The time now is 05:01 PM.

Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.