From 2dacb523fc29fec587865cb4aa4a6ed2c7928b70 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Tue, 7 Oct 2014 23:40:13 -0400 Subject: [PATCH] Rework OPCharCreate logic with tutorial flag Hopefully resolves issues with toons on Titanium spawning out of bounds when starting in tutorial. Resolves setting home bind to tutorial and being out of bounds. --- changelog.txt | 3 ++ common/eq_packet_structs.h | 2 +- common/patches/client62.cpp | 1 + common/patches/client62_structs.h | 2 +- common/patches/rof.cpp | 9 ++--- common/patches/sod.cpp | 8 ++--- common/patches/sof.cpp | 8 ++--- common/patches/titanium.cpp | 1 + common/patches/titanium_structs.h | 2 +- common/patches/underfoot.cpp | 8 ++--- world/client.cpp | 55 +++++++++++++++++++------------ 11 files changed, 50 insertions(+), 49 deletions(-) diff --git a/changelog.txt b/changelog.txt index ed32c03cd..d00864914 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,8 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) ------------------------------------------------------- +== 10/07/2014 == +demonstar55: Identified tutorial flag in all charcreate packets, reworked logic to correctly set homes binds + == 10/05/2014 == Uleat: Added Server<->Corpse slot translators needed for re-enumeration (inactive until phased in) diff --git a/common/eq_packet_structs.h b/common/eq_packet_structs.h index a022626e1..f49c0106c 100644 --- a/common/eq_packet_structs.h +++ b/common/eq_packet_structs.h @@ -689,7 +689,7 @@ struct CharCreate_Struct /*0076*/ uint32 drakkin_heritage; // added for SoF /*0080*/ uint32 drakkin_tattoo; // added for SoF /*0084*/ uint32 drakkin_details; // added for SoF -/*0088*/ +/*0088*/ uint32 tutorial; }; /* diff --git a/common/patches/client62.cpp b/common/patches/client62.cpp index 5afd76bcd..d734a29ec 100644 --- a/common/patches/client62.cpp +++ b/common/patches/client62.cpp @@ -1038,6 +1038,7 @@ namespace Client62 IN(face); IN(eyecolor1); IN(eyecolor2); + IN(tutorial); FINISH_DIRECT_DECODE(); } diff --git a/common/patches/client62_structs.h b/common/patches/client62_structs.h index 24e273682..8c80e34a5 100644 --- a/common/patches/client62_structs.h +++ b/common/patches/client62_structs.h @@ -558,7 +558,7 @@ struct CharCreate_Struct /*0128*/ uint32 face; /*0132*/ uint32 eyecolor1; //its possiable we could have these switched /*0136*/ uint32 eyecolor2; //since setting one sets the other we really can't check -/*0140*/ uint32 unknown140; +/*0140*/ uint32 tutorial; //assumptions are bad! But guessed }; /* diff --git a/common/patches/rof.cpp b/common/patches/rof.cpp index 5fb0f9eed..db1c5487e 100644 --- a/common/patches/rof.cpp +++ b/common/patches/rof.cpp @@ -4036,12 +4036,7 @@ namespace RoF IN(race); IN(class_); IN(deity); - - if (RuleB(World, EnableTutorialButton) && eq->tutorial) - emu->start_zone = RuleI(World, TutorialZoneID); - else - emu->start_zone = eq->start_zone; - + IN(start_zone); IN(haircolor); IN(beard); IN(beardcolor); @@ -4059,7 +4054,7 @@ namespace RoF IN(WIS); IN(INT); IN(CHA); - //IN(tutorial); + IN(tutorial); FINISH_DIRECT_DECODE(); } diff --git a/common/patches/sod.cpp b/common/patches/sod.cpp index 3501e73f0..8c64c479f 100644 --- a/common/patches/sod.cpp +++ b/common/patches/sod.cpp @@ -2705,12 +2705,7 @@ namespace SoD IN(hairstyle); IN(gender); IN(race); - - if (RuleB(World, EnableTutorialButton) && eq->tutorial) - emu->start_zone = RuleI(World, TutorialZoneID); - else - emu->start_zone = eq->start_zone; - + IN(start_zone); IN(haircolor); IN(deity); IN(STR); @@ -2723,6 +2718,7 @@ namespace SoD IN(face); IN(eyecolor1); IN(eyecolor2); + IN(tutorial); IN(drakkin_heritage); IN(drakkin_tattoo); IN(drakkin_details); diff --git a/common/patches/sof.cpp b/common/patches/sof.cpp index 80c0cb7cf..5a1d69bf4 100644 --- a/common/patches/sof.cpp +++ b/common/patches/sof.cpp @@ -2105,12 +2105,7 @@ namespace SoF IN(hairstyle); IN(gender); IN(race); - - if (RuleB(World, EnableTutorialButton) && eq->tutorial) - emu->start_zone = RuleI(World, TutorialZoneID); - else - emu->start_zone = eq->start_zone; - + IN(start_zone); IN(haircolor); IN(deity); IN(STR); @@ -2123,6 +2118,7 @@ namespace SoF IN(face); IN(eyecolor1); IN(eyecolor2); + IN(tutorial); IN(drakkin_heritage); IN(drakkin_tattoo); IN(drakkin_details); diff --git a/common/patches/titanium.cpp b/common/patches/titanium.cpp index 6c2591efe..0366e73d8 100644 --- a/common/patches/titanium.cpp +++ b/common/patches/titanium.cpp @@ -1395,6 +1395,7 @@ namespace Titanium IN(face); IN(eyecolor1); IN(eyecolor2); + IN(tutorial); FINISH_DIRECT_DECODE(); } diff --git a/common/patches/titanium_structs.h b/common/patches/titanium_structs.h index 0e74af75e..17beb6479 100644 --- a/common/patches/titanium_structs.h +++ b/common/patches/titanium_structs.h @@ -565,7 +565,7 @@ struct CharCreate_Struct /*0064*/ uint32 face; // Could be unknown0076 /*0068*/ uint32 eyecolor1; //its possiable we could have these switched /*0073*/ uint32 eyecolor2; //since setting one sets the other we really can't check -/*0076*/ uint32 unknown0076; // Could be face +/*0076*/ uint32 tutorial; /*0080*/ }; diff --git a/common/patches/underfoot.cpp b/common/patches/underfoot.cpp index 34ef61f6e..1caf65bf3 100644 --- a/common/patches/underfoot.cpp +++ b/common/patches/underfoot.cpp @@ -3007,12 +3007,7 @@ namespace Underfoot IN(hairstyle); IN(gender); IN(race); - - if (RuleB(World, EnableTutorialButton) && eq->tutorial) - emu->start_zone = RuleI(World, TutorialZoneID); - else - emu->start_zone = eq->start_zone; - + IN(start_zone); IN(haircolor); IN(deity); IN(STR); @@ -3025,6 +3020,7 @@ namespace Underfoot IN(face); IN(eyecolor1); IN(eyecolor2); + IN(tutorial); IN(drakkin_heritage); IN(drakkin_tattoo); IN(drakkin_details); diff --git a/world/client.cpp b/world/client.cpp index a373004e1..a8f269be1 100644 --- a/world/client.cpp +++ b/world/client.cpp @@ -1345,22 +1345,23 @@ bool Client::OPCharCreate(char *name, CharCreate_Struct *cc) { 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", + 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", + 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); + 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); + clog(WORLD__CLIENT, "Home: %d Tutorial: %d", cc->start_zone, cc->tutorial); /* Validate the char creation struct */ if(ClientVersionBit & BIT_SoFAndLater) { @@ -1475,22 +1476,34 @@ bool Client::OPCharCreate(char *name, CharCreate_Struct *cc) { 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 Home Binds */ + if(!pp.binds[4].zoneId) { + pp.binds[4].zoneId = pp.zone_id; + pp.binds[4].x = pp.x; + pp.binds[4].y = pp.y; + pp.binds[4].z = pp.z; + pp.binds[4].heading = pp.heading; } - /* Set Starting city */ - pp.binds[4] = pp.binds[0]; + /* Overrides if we have the tutorial flag set! */ + if (cc->tutorial && RuleB(World, EnableTutorialButton)) { + pp.zone_id = RuleI(World, TutorialZoneID); + database.GetSafePoints(pp.zone_id, 0, &pp.x, &pp.y, &pp.z); + } + /* Will either be the same as home or tutorial */ + 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; - 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); + clog(WORLD__CLIENT,"Current location: %s (%d) %0.2f, %0.2f, %0.2f, %0.2f", + database.GetZoneName(pp.zone_id), pp.zone_id, pp.x, pp.y, pp.z, pp.heading); + clog(WORLD__CLIENT,"Bind location: %s (%d) %0.2f, %0.2f, %0.2f", + database.GetZoneName(pp.binds[0].zoneId), pp.binds[0].zoneId, pp.binds[0].x, pp.binds[0].y, pp.binds[0].z); + clog(WORLD__CLIENT,"Home location: %s (%d) %0.2f, %0.2f, %0.2f", + database.GetZoneName(pp.binds[4].zoneId), pp.binds[4].zoneId, pp.binds[4].x, pp.binds[4].y, pp.binds[4].z); /* Starting Items inventory */ database.SetStartingItems(&pp, &inv, pp.race, pp.class_, pp.deity, pp.zone_id, pp.name, GetAdmin());