Got 2 bugs now and dont know how to fix this.. :grr:
first:
fixed
second:
Character always male and always human.. In Database is everything right
Any ideas what could be wrong?
Printable View
Got 2 bugs now and dont know how to fix this.. :grr:
first:
fixed
second:
Character always male and always human.. In Database is everything right
Any ideas what could be wrong?
what was the first ?
for the second i got the same, i'm looking why but it's not because of table, i made some printf where the table are load and it load it correcly
Yea I also think its because of the table pctable.
the first was a mistake by me
If you post your UG_CHAR_READY_TO_SPAWN and UG_GAME_ENTER_REQ here, I might help.
Fuuuuuuu try to cast into unsigned char, try to set the data by hand try everything nothing wont work :@
UG_CHAR_READY_TO_SPAWN
UG_GAME_ENTER_REQCode:void CClientSession::SendCharReadyReq(CNtlPacket * pPacket, CGameServer * app)
{
printf("--- CHARACTER READY REQUEST --- \n");
// CREATE OBJECTS
CNtlPacket packet(sizeof(sGU_OBJECT_CREATE));
sGU_OBJECT_CREATE * res = (sGU_OBJECT_CREATE *)packet.GetPacketData();
app->db->prepare("SELECT * FROM characters WHERE CharID = ?");
app->db->setInt(1, this->characterID);
app->db->execute();
app->db->fetch();
CPCTable *pPcTable = app->g_pTableContainer->GetPcTable();
sPC_TBLDAT *pTblData = (sPC_TBLDAT*)pPcTable->GetPcTbldat((int)app->db->getInt("Race"), (int)app->db->getInt("Class"), (int)app->db->getInt("Gender"));
res->wOpCode = GU_OBJECT_CREATE;
res->handle = this->GetavatarHandle();
res->sObjectInfo.objType = OBJTYPE_PC;
res->sObjectInfo.pcBrief.tblidx = app->db->getInt("WorldTable");;
res->sObjectInfo.pcBrief.bIsAdult = app->db->getBoolean("Adult");
wcscpy_s(res->sObjectInfo.pcBrief.awchName, NTL_MAX_SIZE_CHAR_NAME_UNICODE, s2ws(app->db->getString("CharName")).c_str() );
wcscpy_s(res->sObjectInfo.pcBrief.wszGuildName, NTL_MAX_SIZE_GUILD_NAME_IN_UNICODE, L"Solo");
res->sObjectInfo.pcBrief.sPcShape.byFace = app->db->getInt("Face");
res->sObjectInfo.pcBrief.sPcShape.byHair = app->db->getInt("Hair");
res->sObjectInfo.pcBrief.sPcShape.byHairColor = app->db->getInt("HairColor");
res->sObjectInfo.pcBrief.sPcShape.bySkinColor = app->db->getInt("SkinColor");
res->sObjectInfo.pcBrief.wCurLP = app->db->getInt("CurLP");
res->sObjectInfo.pcBrief.wMaxLP = app->db->getInt("BaseMaxLP");
res->sObjectInfo.pcBrief.wCurEP = app->db->getInt("CurEP");
res->sObjectInfo.pcBrief.wMaxEP = app->db->getInt("BaseMaxEP");
res->sObjectInfo.pcBrief.byLevel = app->db->getInt("Level");
res->sObjectInfo.pcBrief.fSpeed = (float)app->db->getDouble("LastRunSpeed");
//Get items which the characters is wearing
for(int i = 0;i < NTL_MAX_EQUIP_ITEM_SLOT;i++)
{
res->sObjectInfo.pcBrief.sItemBrief[i].tblidx = INVALID_TBLIDX; //sAvData.sItem[i].tblidx;
}
res->sObjectInfo.pcBrief.wAttackSpeedRate = app->db->getInt("BaseAttackSpeedRate");
res->sObjectInfo.pcState.sCharStateBase.vCurLoc.x = (float)app->db->getDouble("CurLocX") + (rand()%5);
res->sObjectInfo.pcState.sCharStateBase.vCurLoc.y = (float)app->db->getDouble("CurLocY");
res->sObjectInfo.pcState.sCharStateBase.vCurLoc.z = (float)app->db->getDouble("CurLocZ") + (rand()%5);
res->sObjectInfo.pcState.sCharStateBase.vCurDir.x = (float)app->db->getDouble("CurDirX");
res->sObjectInfo.pcState.sCharStateBase.vCurDir.y = (float)app->db->getDouble("CurDirY");
res->sObjectInfo.pcState.sCharStateBase.vCurDir.z = (float)app->db->getDouble("CurDirZ");
res->sObjectInfo.pcState.sCharStateBase.dwConditionFlag = 0;
res->sObjectInfo.pcState.sCharStateBase.byStateID = 0;
res->sObjectInfo.pcState.sCharStateBase.aspectState.sAspectStateBase.byAspectStateId = 255;
res->sObjectInfo.pcState.sCharStateBase.aspectState.sAspectStateDetail.sGreatNamek.bySourceGrade = 0;
res->sObjectInfo.pcState.sCharStateBase.aspectState.sAspectStateDetail.sKaioken.bySourceGrade = 0;
res->sObjectInfo.pcState.sCharStateBase.aspectState.sAspectStateDetail.sPureMajin.bySourceGrade = 0;
res->sObjectInfo.pcState.sCharStateBase.aspectState.sAspectStateDetail.sSuperSaiyan.bySourceGrade = 0;
res->sObjectInfo.pcState.sCharStateBase.aspectState.sAspectStateDetail.sVehicle.idVehicleTblidx = 0;
memcpy(&this->characterspawnInfo, res, sizeof(sGU_OBJECT_CREATE) );
packet.SetPacketLen( sizeof(sGU_OBJECT_CREATE) );
app->UserBroadcastothers(&packet, this);
app->UserBroadcasFromOthers(GU_OBJECT_CREATE, this);
app->AddUser((const char *)app->db->getString("CharName").c_str(), this);
}
Code://// LOG INTO CHAT-SERVER
printf("--- LOAD CHAT SERVER --- \n");
sUG_GAME_ENTER_REQ * req = (sUG_GAME_ENTER_REQ *)pPacket->GetPacketData();
this->accountID = req->accountId;
this->characterID = req->charId;
CNtlPacket packet(sizeof(sGU_GAME_ENTER_RES));
sGU_GAME_ENTER_RES * res = (sGU_GAME_ENTER_RES *)packet.GetPacketData();
res->wOpCode = GU_GAME_ENTER_RES;
res->wResultCode = GAME_SUCCESS;
strcpy_s(res->achCommunityServerIP, sizeof(res->achCommunityServerIP), "192.168.178.20");
res->wCommunityServerPort = 20400;
packet.SetPacketLen( sizeof(sGU_GAME_ENTER_RES) );
int rc = g_pApp->Send( this->GetHandle(), &packet );
//// SEND CHARACTER INFO
this->avatarHandle = AcquireSerialId();
printf("--- LOAD CHARACTER INFO FOR GAMESERVER --- \n");
CNtlPacket packet2(sizeof(sGU_AVATAR_CHAR_INFO));
sGU_AVATAR_CHAR_INFO * res2 = (sGU_AVATAR_CHAR_INFO *)packet2.GetPacketData();
app->db->prepare("SELECT * FROM characters WHERE CharID = ?");
app->db->setInt(1, req->charId);
app->db->execute();
app->db->fetch();
CPCTable *pPcTable = app->g_pTableContainer->GetPcTable();
sPC_TBLDAT *pTblData = (sPC_TBLDAT*)pPcTable->GetPcTbldat((int)app->db->getInt("Race"), (int)app->db->getInt("Class"), (int)app->db->getInt("Gender"));
res2->wOpCode = GU_AVATAR_CHAR_INFO;
res2->handle = this->avatarHandle;
res2->sPcProfile.tblidx = 1;
res2->sPcProfile.bIsAdult = app->db->getBoolean("Adult");
res2->sPcProfile.charId = app->db->getInt("CharID");
wcscpy_s(res2->sPcProfile.awchName, NTL_MAX_SIZE_CHAR_NAME_UNICODE, s2ws(app->db->getString("CharName")).c_str() );
//PC Shape
res2->sPcProfile.sPcShape.byFace = app->db->getInt("Face");
res2->sPcProfile.sPcShape.byHair = app->db->getInt("Hair");
res2->sPcProfile.sPcShape.byHairColor = app->db->getInt("HairColor");
res2->sPcProfile.sPcShape.bySkinColor = app->db->getInt("SkinColor");
//Character Attribute
res2->sPcProfile.avatarAttribute.byBaseStr = app->db->getInt("BaseStr");
res2->sPcProfile.avatarAttribute.byLastStr = app->db->getInt("LastStr");
res2->sPcProfile.avatarAttribute.byBaseCon = app->db->getInt("BaseCon");
res2->sPcProfile.avatarAttribute.byLastCon = app->db->getInt("LastCon");
res2->sPcProfile.avatarAttribute.byBaseFoc = app->db->getInt("BaseFoc");
res2->sPcProfile.avatarAttribute.byLastFoc = app->db->getInt("LastFoc");
res2->sPcProfile.avatarAttribute.byBaseDex = app->db->getInt("BaseDex");
res2->sPcProfile.avatarAttribute.byLastDex = app->db->getInt("LastDex");
res2->sPcProfile.avatarAttribute.byBaseSol = app->db->getInt("BaseSol");
res2->sPcProfile.avatarAttribute.byLastSol = app->db->getInt("LastSol");
res2->sPcProfile.avatarAttribute.byBaseEng = app->db->getInt("BaseEng");
res2->sPcProfile.avatarAttribute.byLastEng = app->db->getInt("LastEng");
res2->sPcProfile.avatarAttribute.wBaseMaxLP = app->db->getInt("BaseMaxLP");
res2->sPcProfile.avatarAttribute.wLastMaxLP = app->db->getInt("BaseMaxLP");
res2->sPcProfile.avatarAttribute.wBaseMaxEP = app->db->getInt("BaseMaxEP");
res2->sPcProfile.avatarAttribute.wLastMaxEP = app->db->getInt("BaseMaxEP");
res2->sPcProfile.avatarAttribute.wBaseMaxRP = app->db->getInt("BaseMaxRP");
res2->sPcProfile.avatarAttribute.wLastMaxRP = app->db->getInt("BaseMaxRP");
res2->sPcProfile.avatarAttribute.wBasePhysicalOffence = app->db->getInt("BasePhysicalOffence");
res2->sPcProfile.avatarAttribute.wLastPhysicalOffence = app->db->getInt("LastPhysicalOffence");
res2->sPcProfile.avatarAttribute.wBasePhysicalDefence = app->db->getInt("BasePhysicalDefence");
res2->sPcProfile.avatarAttribute.wLastPhysicalDefence = app->db->getInt("LastPhysicalDefence");
res2->sPcProfile.avatarAttribute.wBaseEnergyOffence = app->db->getInt("BaseEnergyOffence");
res2->sPcProfile.avatarAttribute.wLastEnergyOffence = app->db->getInt("LastEnergyOffence");
res2->sPcProfile.avatarAttribute.wBaseEnergyDefence = app->db->getInt("BaseEnergyDefence");
res2->sPcProfile.avatarAttribute.wLastEnergyDefence = app->db->getInt("LastEnergyDefence");
res2->sPcProfile.avatarAttribute.wBaseAttackRate = app->db->getInt("BaseAttackRate");
res2->sPcProfile.avatarAttribute.wLastAttackRate = app->db->getInt("LastAttackRate");
res2->sPcProfile.avatarAttribute.wBaseDodgeRate = app->db->getInt("BaseDodgeRate");
res2->sPcProfile.avatarAttribute.wLastDodgeRate = app->db->getInt("LastDodgeRate");
res2->sPcProfile.avatarAttribute.wBaseBlockRate = app->db->getInt("BaseBlockRate");
res2->sPcProfile.avatarAttribute.wLastBlockRate = app->db->getInt("LastBlockRate");
res2->sPcProfile.avatarAttribute.wLastPhysicalCriticalRate = app->db->getInt("LastPhysicalCriticalRate");
res2->sPcProfile.avatarAttribute.wLastEnergyCriticalRate = app->db->getInt("LastEnergyCriticalRate");
res2->sPcProfile.avatarAttribute.fLastRunSpeed = (float)app->db->getDouble("LastRunSpeed");
res2->sPcProfile.wCurLP = app->db->getInt("CurLP");
res2->sPcProfile.wCurEP = app->db->getInt("CurEP");
res2->sPcProfile.wCurRP = app->db->getInt("CurRP");
res2->sPcProfile.byLevel = app->db->getInt("Level");
res2->sPcProfile.dwCurExp = app->db->getInt("Exp");
res2->sPcProfile.dwMaxExpInThisLevel = app->db->getInt("MaxExpInThisLevel");
res2->sPcProfile.dwZenny = app->db->getInt("Money");
res2->sPcProfile.dwTutorialHint = 0;
res2->sPcProfile.dwReputation = app->db->getInt("Reputation");
res2->sPcProfile.dwMudosaPoint = app->db->getInt("MudosaPoint");
res2->sPcProfile.dwSpPoint = app->db->getInt("SpPoint");
// Character State
res2->sCharState.sCharStateBase.vCurLoc.x = (float)app->db->getDouble("CurLocX");
res2->sCharState.sCharStateBase.vCurLoc.y = (float)app->db->getDouble("CurLocY");
res2->sCharState.sCharStateBase.vCurLoc.z = (float)app->db->getDouble("CurLocZ");
res2->sCharState.sCharStateBase.vCurDir.x = (float)app->db->getDouble("CurDirX");
res2->sCharState.sCharStateBase.vCurDir.y = (float)app->db->getDouble("CurDirY");
res2->sCharState.sCharStateBase.vCurDir.z = (float)app->db->getDouble("CurDirZ");
res2->sCharState.sCharStateBase.dwConditionFlag = 0;
res2->sCharState.sCharStateBase.byStateID = 0;
res2->sCharState.sCharStateBase.aspectState.sAspectStateBase.byAspectStateId = 255;
res2->sCharState.sCharStateBase.aspectState.sAspectStateDetail.sGreatNamek.bySourceGrade = 0;
res2->sCharState.sCharStateBase.aspectState.sAspectStateDetail.sKaioken.bySourceGrade = 0;
res2->sCharState.sCharStateBase.aspectState.sAspectStateDetail.sPureMajin.bySourceGrade = 0;
res2->sCharState.sCharStateBase.aspectState.sAspectStateDetail.sSuperSaiyan.bySourceGrade = 0;
res2->sCharState.sCharStateBase.aspectState.sAspectStateDetail.sVehicle.idVehicleTblidx = 0;
res2->wCharStateSize = sizeof(sCHARSTATE_BASE);
res2->sPcProfile.bIsGameMaster = app->db->getBoolean("GameMaster");
packet2.SetPacketLen( sizeof(sGU_AVATAR_CHAR_INFO) );
rc = g_pApp->Send( this->GetHandle(), &packet2 );
// END AVATAR INFO
CNtlPacket packet3(sizeof(sGU_AVATAR_INFO_END));
sGU_AVATAR_INFO_END * res3 = (sGU_AVATAR_INFO_END *)packet3.GetPacketData();
res3->wOpCode = GU_AVATAR_INFO_END;
packet3.SetPacketLen( sizeof(sGU_AVATAR_INFO_END) );
rc = g_pApp->Send( this->GetHandle(), &packet3 );
you have community server Oo ?
Test the database, if it chooses the right character.
Everything seems to be fine.
Mine works like a charm and it's almost the same, just diffrent structured.
Database must be right too.
http://s14.directupload.net/images/140618/5n89wmrq.jpg
No I dont have community server
Make a cout in your gameserver with the Characters ID and Account ID just to check if it's the right character that your gameserver recives from charserver.
And yea, I already tested with printf. It selects the right char id and everything else right :/
There must be something wrong with this I bet:
Quote:
CPCTable *pPcTable = app->g_pTableContainer->GetPcTable();
sPC_TBLDAT *pTblData = (sPC_TBLDAT*)pPcTable->GetPcTbldat((int)app->db->getInt("Race"), (int)app->db->getInt("Class"), (int)app->db->getInt("Gender"));
res->sObjectInfo.pcBrief.tblidx = app->db->getInt("WorldTable");;
is wrong
it should be
res->sObjectInfo.pcBrief.tblidx = pTblData->tblidx;
edit: ok changed..
if I have
then the gameserver crash on log inQuote:
res->sObjectInfo.pcBrief.tblidx = pTblData->tblidx;
but if I have
then everything works o.OQuote:
res->sObjectInfo.pcBrief.tblidx = 1;
Try with printf and what send to you pTblData->tblidx;
doesnt work. The gameserver crashes if I want to get the result with printf
in the trace?
its empty
if its empty than maybe
CPCTable *pPcTable = app->g_pTableContainer->GetPcTable();
sPC_TBLDAT *pTblData = (sPC_TBLDAT*)pPcTable->GetPcTbldat((int)app->db->getInt("Race"), (int)app->db->getInt("Class"), (int)app->db->getInt("Gender"));
gives you a NULL pointer for pTableData
you should make sure you have loaded the pctable it self in the first place else everything from it is NULL
Just fine something,
m_aPcTbldat[byRace][byClass][byGender]
this function return a NULL pointer i'm looking why.
ok ive tryed now
and this also crashes the gameserver. So there must be a problem withQuote:
printf(" %i \n", pTblData->byRace);
?Quote:
CPCTable *pPcTable = app->g_pTableContainer->GetPcTable();
is good, i think the table initialisation is not do or is not good, if you look all the function of PCTable there is a :Quote:
CPCTable *pPcTable = app->g_pTableContainer->GetPcTable();
but i don't know how to use it at the moment.Quote:
bool CPCTable::SetPcTbldat(BYTE byRace, BYTE byClass, BYTE byGender, sTBLDAT * pTbldat)
http://s7.directupload.net/images/140619/woc2zdd3.jpg
working now. thanks!
how ^^ ?
Oh, i can't see my name D: