• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

[Development] Season 12 Dataserver decompilation

Newbie Spellweaver
Joined
Jun 20, 2016
Messages
51
Reaction score
41
hello I leave the decompilation of the two functions, you should adapt a bit the issue of the execution of scripts and other sql since it uses the one of my emulator but it will not be a problem

Structs

Code:
#define MAX_MUUN_INVENTORY_SLOT 102

struct _tagSDHP_REQ_MUUN_PERIOD_INFO_SELECT_RECV{    PSBMSG_HEAD header;    //C1:4E:20    char Name[11];    WORD aIndex;};

struct _stMuunPeriodInfoList{    WORD wItemType;    DWORD dwSerial;    int lItemExpireDate;};

Funcion GDReqMuunPeriodInfoSelect

Code:
void GDReqMuunPeriodInfoSelect(_tagSDHP_REQ_MUUN_PERIOD_INFO_SELECT_RECV *lpMsg, int aIndex){    _stMuunPeriodInfoList MuunListInfo[MAX_MUUN_INVENTORY_SLOT];    BYTE btListCnt = 0;    bool Result = gMuunSystemDBSet.SelectMuunPeriodInfo(lpMsg->Name,MuunListInfo,&btListCnt);    if (Result == false)    {        return;    }    _tagSDHP_ANS_MUUN_PERIOD_INFO_SELECT_SEND pMsg;    BYTE send[4104];    int size = sizeof(pMsg);    memcpy(&send[size], MuunListInfo, (sizeof(_stMuunPeriodInfoList) * btListCnt));    size += (sizeof(_stMuunPeriodInfoList) * btListCnt) + sizeof(_tagSDHP_ANS_MUUN_PERIOD_INFO_SELECT_SEND);    pMsg.btResult = Result;    pMsg.aIndex = lpMsg->aIndex;    pMsg.btCnt = btListCnt;    pMsg.header.set(0x4E, 0x20, size);    memcpy(send, &pMsg, sizeof(pMsg));    gSocketManagerDataServer.DataSend(aIndex, send, size);}

//---------------------------------------------------------------------------------

bool CMuunSystemDBSet::SelectMuunPeriodInfo(char *szName, _stMuunPeriodInfoList *MuunPeriodInfoList, BYTE *btListCnt){    if (gQueryManager.ExecQuery("EXEC WZ_MuunPeriodSelect '%s'",szName) == 0)    {        gQueryManager.Close();        LogAdd(LOG_RED, "error-L3 : [MuunSystem] SelectMuunPeriodInfo #1 [%s]", szName);        return 0;    }    int iCnt = 0;    for (SQLRETURN SQLReturn = gQueryManager.Fetch(); SQLReturn != SQL_NO_DATA && SQLReturn != SQL_ERROR; SQLReturn = gQueryManager.Fetch())    {        if (iCnt > (MAX_MUUN_INVENTORY_SLOT - 1))        {            gQueryManager.Close();            LogAdd(LOG_RED, "error-L3 : [MuunSystem] higher than MAX_MUUN_INVENTORY #1 [%s]", szName);            break;        }        MuunPeriodInfoList[iCnt].wItemType = gQueryManager.GetAsInteger("ItemType");        MuunPeriodInfoList[iCnt].dwSerial = (DWORD)gQueryManager.GetAsInteger64("Serial");        MuunPeriodInfoList[iCnt].lItemExpireDate = gQueryManager.GetAsInteger("ExpireDateConvert");        iCnt++;    }    *btListCnt = iCnt;    gQueryManager.Close();    return true;}


Code:
struct SDHP_GETCHARLIST_RECV{    PBMSG_HEAD header;    // C1:01    char Account[10];    WORD Index;    int IsUnityBattleFiledServer;};

struct SDHP_CHARLISTCOUNT_SEND{    PWMSG_HEAD header;    // C1:01    WORD Index;    BYTE Count;    int DbNumber;    BYTE GenerableClass;    char AccountId[11];    BYTE MoveCnt;    BYTE CharacterSlotCount;    BYTE ExtendedWarehouseCount;};

struct AccountCharacterInfo{    int DBNumber;    char AccountId[11];    char GameID1[11];    char GameID2[11];    char GameID3[11];    char GameID4[11];    char GameID5[11];    BYTE CtlCode;    BYTE MoveCnt;};
struct SDHP_CHARLIST{    BYTE Index;    char Name[10];    char UnityBFOfRealName[10];    WORD ServerCodeOfHomeWorld;    WORD Level;    BYTE Class;    BYTE CtlCode;    BYTE dbInventory[48];    BYTE DbVersion;    BYTE btGuildStatus;    BYTE PK_Level;};


Funcion GJPCharacterListRequestCS (I do not leave it complete because it gives me straw continue copying the code, but surely you can perform the functions that are missing without problems)


Code:
void GJPCharacterListRequestCS(SDHP_GETCHARLIST_RECV *lpMsg, int aIndex){    DGAccountInfoSend(lpMsg->Index, lpMsg->Account);    BYTE Buffer[520];    SDHP_CHARLISTCOUNT_SEND pMsg;    int size = sizeof(pMsg);    pMsg.header.set(0x01, size);    memcpy(pMsg.AccountId, lpMsg->Account, sizeof(pMsg.AccountId));    pMsg.GenerableClass = 0;    pMsg.Count = 0;    pMsg.Index = lpMsg->Index;    if (gAccountCharDBSet.GetAccountId(lpMsg->Account) == false && gAccountCharDBSet.CreateAccountCharacter(lpMsg->Account) == false)    {        memcpy(Buffer, &pMsg, sizeof(pMsg));        gSocketManagerDataServer.DataSend(aIndex, Buffer, size);        return;    }    BYTE btSlotCount = 0;    if (gAccountCharDBSet.GetCharacterSlotCount(lpMsg->Account, &btSlotCount) == true)    {        pMsg.CharacterSlotCount = btSlotCount;    }    BYTE btAddExtendedWarehouseCount = 0;    if (gAccountCharDBSet.GetCharacterExtendedWarehouseCount(lpMsg->Account, &btAddExtendedWarehouseCount) == true)    {        pMsg.ExtendedWarehouseCount = btAddExtendedWarehouseCount;    }    AccountCharacterInfo ACInfo;    memset(&ACInfo, 0, sizeof(ACInfo));    if (gAccountCharDBSet.GetAccountInfo(lpMsg->Account, &ACInfo) == false)    {        memcpy(Buffer, &pMsg, sizeof(pMsg));        gSocketManagerDataServer.DataSend(aIndex, Buffer, size);        return;    }    char Names[MAX_CHARACTER][11];    memcpy(Names[0], ACInfo.GameID1, sizeof(ACInfo.GameID1));    memcpy(Names[1], ACInfo.GameID2, sizeof(ACInfo.GameID2));    memcpy(Names[2], ACInfo.GameID3, sizeof(ACInfo.GameID3));    memcpy(Names[3], ACInfo.GameID4, sizeof(ACInfo.GameID4));    memcpy(Names[4], ACInfo.GameID5, sizeof(ACInfo.GameID5));    pMsg.MoveCnt = ACInfo.MoveCnt;    SDHP_CHARLIST info;    for (int i = 0; i < MAX_CHARACTER; ++i)    {        int Len = strlen(Names[i]);        if (Len <= 0 || Len > 10)        {            continue;        }        BYTE _ctlcode = 0;        BYTE _dbverstion = 0;        BYTE _pkLevel = 0;        BYTE _btGuildStatus = -1;        int _level = 0;        int _class = 0;        BYTE Inventory[3800];        memset(Inventory, 0xFF, sizeof(Inventory));        if (gCharPreviewDBSet.GetChar(Names[i], lpMsg->Account, &_level, &_class, Inventory, &_ctlcode, &_dbverstion, &_pkLevel, &_btGuildStatus) == false)        {            continue;        }        info.Index = i;        info.Level = _level;        info.Class = _class;        info.CtlCode = _ctlcode;        info.DbVersion = _dbverstion;        // Cambiar  a una funcion la migracion del SpeedServer        if (_pkLevel & 0x80)            {            LogAdd(LOG_BLACK, "Speed server migration [Account:%s][Name:%s][level:%d]", lpMsg->Account, Names[i], _level);            _pkLevel &= 0x7F;            WORD MasterLevel = 0;            MLP_ANS_MASTERLEVEL_INFO_SEND MasterInfo;            if (_level >= 400 && gMasterLevelSystemDBSet.DSDB_QueryMasterLevelSystemLoad(Names[i], &MasterInfo) == false)            {                MasterLevel = MasterInfo.nMLevel;            }            BYTE ClassType = 4 * gClassdef.GetCharacterClassByDBClass(_class);            if (ClassType == CLASS_NONE)            {                continue;            }            BYTE InventoryData[(MAX_ITEM_SECTION - 1)*INVENTORY_WEAR_SIZE];            memset(InventoryData, -1, sizeof(InventoryData));            if ((MasterLevel + _level) >= 600)            {                gItem.ItemByteConvert16(InventoryData, gClassdef.JumpingEquipment[ClassType + 3], INVENTORY_EXT4_SIZE);            }            else if ((MasterLevel + _level) >= 500)            {                gItem.ItemByteConvert16(InventoryData, gClassdef.JumpingEquipment[ClassType + 1], INVENTORY_EXT4_SIZE);            }            else if (_level >= 400)            {                gItem.ItemByteConvert16(InventoryData, gClassdef.JumpingEquipment[ClassType], INVENTORY_EXT4_SIZE);            }            else if (_level >= 380)            {                gItem.ItemByteConvert16(InventoryData, gClassdef.JumpingEquipment[ClassType + 2], INVENTORY_EXT4_SIZE);            }            else            {                CItem ItemInfo[(INVENTORY_WEAR_SIZE + 1)];                for (int k = 0; k < (INVENTORY_WEAR_SIZE + 1); ++k)                {                    ItemInfo[k].Clear();                }                WORD type = gItem.ItemGetNumberMake(14, 286);                ItemInfo[12].Convert(type, 0, 0, 0, 0, 0, 3);                gItem.ItemByteConvert16(InventoryData, ItemInfo, (INVENTORY_WEAR_SIZE + 1));            }            gCharDBSet.RewardJumpingItem(Names[i], InventoryData);        }        // -----------        info.PK_Level = _pkLevel;        info.btGuildStatus = _btGuildStatus;        memcpy(info.UnityBFOfRealName, "", sizeof(info.UnityBFOfRealName));        info.ServerCodeOfHomeWorld = 0;        gCharPreviewDBSet.GetRealNameAndServerCode(Names[i], info.UnityBFOfRealName, &info.ServerCodeOfHomeWorld, lpMsg->IsUnityBattleFiledServer);        memcpy(info.Name, Names[i], sizeof(info.Name));        if ((_ctlcode & 0x80) == 0 && _level >= 150)        {            if (_level < 200 && pMsg.GenerableClass < 2)            {                pMsg.GenerableClass = 1;            }            else if (_level >= 200 && pMsg.GenerableClass < 3)            {                pMsg.GenerableClass = 2;            }            else if (_level >= 220 && pMsg.GenerableClass < 4)            {                pMsg.GenerableClass = 3;            }            else if (_level >= 250 && pMsg.GenerableClass < 5)            {                pMsg.GenerableClass = 4;            }            else if (_level >= 400)            {                pMsg.GenerableClass = 5;            }        }        for (int n = 0; n < INVENTORY_WEAR_SIZE; ++n)        {            switch (_dbverstion)            {                case 0x00:                    memcpy(&info.dbInventory[2 * n], &Inventory[7 * n], sizeof(WORD));                    continue;                case 0x01:                case 0x02:                    memcpy(&info.dbInventory[3 * n], &Inventory[10 * n], sizeof(WORD));                    info.dbInventory[3 * n + 2] = Inventory[10 * n + 7];                    continue;                case 0x03:                    memcpy(&info.dbInventory[4 * n], &Inventory[16 * n], sizeof(WORD));                    info.dbInventory[4 * n + 2] = Inventory[16 * n + 7];                    info.dbInventory[4 * n + 3] = Inventory[16 * n + 9];                    continue;            }        }        memcpy(&Buffer[size], &info, sizeof(info));        size += sizeof(info);        pMsg.Count++;    }    pMsg.header.size[0] = SET_NUMBERHB(size);    pMsg.header.size[1] = SET_NUMBERLB(size);    memcpy(Buffer, &pMsg, sizeof(pMsg));    gSocketManagerDataServer.DataSend(aIndex, Buffer, size);}

pd:I have to relearn the code a bit since I did the quick decompilation maybe it was already a mistake but I doubt a lot since they are simple things
 
Back
Top