bool Client::OPCharCreate(char *name, CharCreate_Struct *cc) { PlayerProfile_Struct pp; ExtendedProfile_Struct ext; Inventory inv; time_t bday = time(nullptr); char startzone[50]={0}; uint32 i; struct in_addr in; int stats_sum = cc->STR + cc->STA + cc->AGI + cc->DEX + cc->WIS + cc->INT + cc->CHA; in.s_addr = GetIP(); clog(WORLD__CLIENT,"Character creation request from %s LS#%d (%s:%d) : ", GetCLE()->LSName(), GetCLE()->LSID(), inet_ntoa(in), GetPort()); clog(WORLD__CLIENT,"Name: %s", name); clog(WORLD__CLIENT,"Race: %d Class: %d Gender: %d Deity: %d Start zone: %d", cc->race, cc->class_, cc->gender, cc->deity, cc->start_zone); clog(WORLD__CLIENT,"STR STA AGI DEX WIS INT CHA Total"); clog(WORLD__CLIENT,"%3d %3d %3d %3d %3d %3d %3d %3d", cc->STR, cc->STA, cc->AGI, cc->DEX, cc->WIS, cc->INT, cc->CHA, stats_sum); clog(WORLD__CLIENT,"Face: %d Eye colors: %d %d", cc->face, cc->eyecolor1, cc->eyecolor2); clog(WORLD__CLIENT,"Hairstyle: %d Haircolor: %d", cc->hairstyle, cc->haircolor); clog(WORLD__CLIENT,"Beard: %d Beardcolor: %d", cc->beard, cc->beardcolor); // Convert incoming cc_s to the new PlayerProfile_Struct memset(&pp, 0, sizeof(PlayerProfile_Struct)); // start building the profile InitExtendedProfile(&ext); strn0cpy(pp.name, name, 63); // clean the capitalization of the name #if 0 // on second thought, don't - this will just make the creation fail // because the name won't match what was already reserved earlier for (i = 0; pp.name[i] && i < 63; i++) { if(!isalpha(pp.name[i])) return false; pp.name[i] = tolower(pp.name[i]); } pp.name[0] = toupper(pp.name[0]); #endif pp.race = cc->race; pp.class_ = cc->class_; pp.gender = cc->gender; pp.deity = cc->deity; pp.STR = cc->STR; pp.STA = cc->STA; pp.AGI = cc->AGI; pp.DEX = cc->DEX; pp.WIS = cc->WIS; pp.INT = cc->INT; pp.CHA = cc->CHA; pp.face = cc->face; pp.eyecolor1 = cc->eyecolor1; pp.eyecolor2 = cc->eyecolor2; pp.hairstyle = cc->hairstyle; pp.haircolor = cc->haircolor; pp.beard = cc->beard; pp.beardcolor = cc->beardcolor; pp.drakkin_heritage = cc->drakkin_heritage; pp.drakkin_tattoo = cc->drakkin_tattoo; pp.drakkin_details = cc->drakkin_details; pp.birthday = bday; pp.lastlogin = bday; pp.level = 1; pp.points = 5; pp.cur_hp = 1000; // 1k hp during dev only //what was the point of this? zone dosent handle this: //pp.expAA = 0xFFFFFFFF; pp.hunger_level = 6000; pp.thirst_level = 6000; // FIXME: FV roleplay, database goodness... // Racial Languages SetRacialLanguages( &pp ); SetRaceStartingSkills( &pp ); SetClassStartingSkills( &pp ); for(i = 0; i < MAX_PP_SPELLBOOK; i++) pp.spell_book[i] = 0xFFFFFFFF; for(i = 0; i < MAX_PP_MEMSPELL; i++) pp.mem_spells[i] = 0xFFFFFFFF; for(i = 0; i < BUFF_COUNT; i++) pp.buffs[i].spellid = 0xFFFF; //If server is PVP by default, make all character set to it. pp.pvp = database.GetServerType() == 1 ? 1 : 0; // if there's a startzone variable put them in there if(database.GetVariable("startzone", startzone, 50)) { clog(WORLD__CLIENT,"Found 'startzone' variable setting: %s", startzone); pp.zone_id = database.GetZoneID(startzone); if(pp.zone_id) database.GetSafePoints(pp.zone_id, 0, &pp.x, &pp.y, &pp.z); else clog(WORLD__CLIENT_ERR,"Error getting zone id for '%s'", startzone); } else // otherwise use normal starting zone logic { bool ValidStartZone = false; ValidStartZone = database.GetStartZone(&pp, cc); if(!ValidStartZone) return false; } if(!pp.zone_id) { pp.zone_id = 1; // qeynos pp.x = pp.y = pp.z = -1; } if(!pp.binds[0].zoneId) { pp.binds[0].zoneId = pp.zone_id; pp.binds[0].x = pp.x; pp.binds[0].y = pp.y; pp.binds[0].z = pp.z; pp.binds[0].heading = pp.heading; } // set starting city location to the initial bind point pp.binds[4] = pp.binds[0]; clog(WORLD__CLIENT,"Current location: %s %0.2f, %0.2f, %0.2f, %0.2f", database.GetZoneName(pp.zone_id), pp.x, pp.y, pp.z, pp.heading); clog(WORLD__CLIENT,"Bind location: %s %0.2f, %0.2f, %0.2f", database.GetZoneName(pp.binds[0].zoneId), pp.binds[0].x, pp.binds[0].y, pp.binds[0].z); // Starting Items inventory database.SetStartingItems(&pp, &inv, pp.race, pp.class_, pp.deity, pp.zone_id, pp.name, GetAdmin()); // now we give the pp and the inv we made to StoreCharacter // to see if we can store it if (!database.StoreCharacter(GetAccountID(), &pp, &inv, &ext)) { clog(WORLD__CLIENT_ERR,"Character creation failed: %s", pp.name); return false; } else { clog(WORLD__CLIENT,"Character creation successful: %s", pp.name); return true; } }
bool Client::OPCharCreate(char *name, CharCreate_Struct *cc) { PlayerProfile_Struct pp; ExtendedProfile_Struct ext; Inventory inv; time_t bday = time(nullptr); char startzone[50]={0}; uint32 i; struct in_addr in; int stats_sum = cc->STR + cc->STA + cc->AGI + cc->DEX + cc->WIS + cc->INT + cc->CHA; in.s_addr = GetIP(); if(cc->face == 0 && cc->oldface > 0) cc->face = cc->oldface; clog(WORLD__CLIENT, "Character creation request from %s LS#%d (%s:%d) : ", GetCLE()->LSName(), GetCLE()->LSID(), inet_ntoa(in), GetPort()); clog(WORLD__CLIENT, "Name: %s", name); clog(WORLD__CLIENT, "Race: %d Class: %d Gender: %d Deity: %d Start zone: %d", cc->race, cc->class_, cc->gender, cc->deity, cc->start_zone); clog(WORLD__CLIENT, "STR STA AGI DEX WIS INT CHA Total"); clog(WORLD__CLIENT, "%3d %3d %3d %3d %3d %3d %3d %3d", cc->STR, cc->STA, cc->AGI, cc->DEX, cc->WIS, cc->INT, cc->CHA, stats_sum); clog(WORLD__CLIENT, "Face: %d Eye colors: %d %d", cc->face, cc->eyecolor1, cc->eyecolor2); clog(WORLD__CLIENT, "Hairstyle: %d Haircolor: %d", cc->hairstyle, cc->haircolor); clog(WORLD__CLIENT, "Beard: %d Beardcolor: %d", cc->beard, cc->beardcolor); /* Validate the char creation struct */ if(!CheckCharCreateInfo(cc)) { clog(WORLD__CLIENT_ERR,"CheckCharCreateInfo did not validate the request (bad race/class/stats)"); return false; } /* Convert incoming cc_s to the new PlayerProfile_Struct */ memset(&pp, 0, sizeof(PlayerProfile_Struct)); // start building the profile strn0cpy(pp.name, name, 63); pp.race = cc->race; pp.class_ = cc->class_; pp.gender = cc->gender; pp.deity = cc->deity; pp.STR = cc->STR; pp.STA = cc->STA; pp.AGI = cc->AGI; pp.DEX = cc->DEX; pp.WIS = cc->WIS; pp.INT = cc->INT; pp.CHA = cc->CHA; pp.face = cc->face; pp.eyecolor1 = cc->eyecolor1; pp.eyecolor2 = cc->eyecolor2; pp.hairstyle = cc->hairstyle; pp.haircolor = cc->haircolor; pp.beard = cc->beard; pp.beardcolor = cc->beardcolor; pp.birthday = bday; pp.lastlogin = bday; pp.level = 1; pp.points = 5; pp.cur_hp = 1000; // 1k hp during dev only pp.hunger_level = 6000; pp.thirst_level = 6000; /* Set Racial and Class specific language and skills */ SetRacialLanguages(&pp); SetRaceStartingSkills(&pp); SetClassStartingSkills(&pp); SetClassLanguages(&pp); for (i = 0; i < MAX_PP_REF_SPELLBOOK; i++) pp.spell_book[i] = 0xFFFFFFFF; for(i = 0; i < MAX_PP_REF_MEMSPELL; i++) pp.mem_spells[i] = 0xFFFFFFFF; for(i = 0; i < BUFF_COUNT; i++) pp.buffs[i].spellid = 0xFFFF; /* If server is PVP by default, make all character set to it. */ pp.pvp = database.GetServerType() == 1 ? 1 : 0; // if there's a startzone variable put them in there if(database.GetVariable("startzone", startzone, 50)) { clog(WORLD__CLIENT,"Found 'startzone' variable setting: %s", startzone); pp.zone_id = database.GetZoneID(startzone); if(pp.zone_id) database.GetSafePoints(pp.zone_id, 0, &pp.x, &pp.y, &pp.z); else clog(WORLD__CLIENT_ERR,"Error getting zone id for '%s'", startzone); } else // otherwise use normal starting zone logic { bool ValidStartZone = false; ValidStartZone = database.GetStartZone(&pp, cc); if(!ValidStartZone) return false; } /* just in case */ if (!pp.zone_id) { pp.zone_id = qeynos; pp.x = pp.y = pp.z = -1; } if (!pp.binds[0].zoneId) { pp.binds[0].zoneId = pp.zone_id; pp.binds[0].x = pp.x; pp.binds[0].y = pp.y; pp.binds[0].z = pp.z; pp.binds[0].heading = pp.heading; } // set starting city location to the initial bind point pp.binds[4] = pp.binds[0]; clog(WORLD__CLIENT, "Current location: %s %0.2f, %0.2f, %0.2f, %0.2f", database.GetZoneName(pp.zone_id), pp.x, pp.y, pp.z, pp.heading); clog(WORLD__CLIENT, "Bind location: %s %0.2f, %0.2f, %0.2f", database.GetZoneName(pp.binds[0].zoneId), pp.binds[0].x, pp.binds[0].y, pp.binds[0].z); /* Starting Items inventory */ database.SetStartingItems(&pp, &inv, pp.race, pp.class_, pp.deity, pp.zone_id, pp.name, GetAdmin()); // now we give the pp and the inv we made to StoreCharacter // to see if we can store it if (!database.StoreCharacter(GetAccountID(), &pp, &inv)) { clog(WORLD__CLIENT_ERR,"Character creation failed: %s", pp.name); return false; } clog(WORLD__CLIENT,"Character creation successful: %s", pp.name); return true; }