PDA

View Full Version : ZoneProxy and DR3


Mrwalsh
01-27-2004, 03:02 PM
Does ZoneProxy work with DR3 yet? I have the DR2 versions, found what was changed where, and made the same changes to my DR3 sources, but I was having trouble with the client_process.cpp, mainly initialization and declaration errors. Were variables changed or something done that affects what the ZoneProxy changes are trying to do?

Windcatcher
01-27-2004, 05:56 PM
I don't know -- I've never seen DR3. I'm hoping the devs get the ZP stuff into the general release, possibly bracketed between #ZONEPROXY declarations...

WC

Kroeg
01-27-2004, 06:04 PM
I'm hoping for the same as well. It sure would be nice to be able to stay up to date yet still work on zonebuilding at the same time.

Mrwalsh
01-27-2004, 07:06 PM
So am I. I'd like to get started on custom zones and whatnot, but I'm running DR3 at the moment. Soon, hopefully!

Shawn319
01-27-2004, 07:53 PM
i tried to merge openzone several times and it failed to compile hehe.. you need to get latest DR-3 and merge yourself, compile, if it works, post the diff's here so someone can merge it.

Shadow-Wolf
01-27-2004, 08:04 PM
i tried to merge openzone several times and it failed to compile hehe.. you need to get latest DR-3 and merge yourself, compile, if it works, post the diff's here so someone can merge it.
Openzone? do you mean the zoneproxy friendly changes to the eqemu source? lol

Kroeg
01-28-2004, 01:56 AM
If WC was able to merge it in, then I'm sure at least one of the developers could... if they wanted to that is. Simply dropping the .cpp/h files into the source folders and compiling of course will bring up errors.

Mrwalsh
01-28-2004, 05:08 AM
What I did was download WC's DR2 ZP files, unzip 'em, did a search of the new folder for any files with ZONEPROXY BEGIN in the file (as this would pull up any changes WC made), found each change, and applied those changes to each corresponding DR3 file. World.exe compiled fine, but there was a problem with client_process.cpp in the /zone compilation that wouldn't let it go. So there's something else going on inside that file that the changes didn't get along with.

Kroeg
01-28-2004, 07:11 AM
Being an over-glorified VB/Java coder (did I say coder? lol.. no flames please) I don't know much about C++. I did exactly the same as you, and merged each line with //ZONEPROXY BEGIN and //ZONEPROXY END to each corresponding cpp/h file, compiled and it went fine all except for a few little instances.

In theory, I'll assume this is because code has to be sequenced in certain ways to be able to utilize its function. There could be a case that where the ZP friendly changes were last time, there may be new code that requires whichever line you're on to be complete. Mergining in the ZP friendly code where it was last time, may cut-off whichever string of code you merged it into (im rambling, and I'm sitting in programming class at school.. so of course I'm doomed to ramble more)

Windcatcher
01-28-2004, 11:56 AM
They probably just renamed a variable or something. If you look at the CVS log for each file I changed it should show what changes were made since then and give an idea of what needs to be done. I first made the ZP changes with 0.5.1, and the difference between that and 0.5.3 was mostly renamed variables or struct members.

I have to admit I'm getting tired of having to do this same merge every time the CVS changes, and I have to keep up with the Admin Tool and OpenZone as well. The code just can't have changed that much between DR2 and DR3...

WC

Shawn319
01-28-2004, 04:29 PM
If you can post some firm, working diff's (not whole files) i can almost guarantee you it will get merged into the public cvs eventually.

Your best bet is to #ifdef ZONEPROXY, #else, #endif, etc.... that way the other devs will have no trouble with it being included in releases.

farce
01-28-2004, 05:01 PM
shawn, i merged it with your dr3 today, complete with #ifdefs

i'll diff it tomorrow

Shadow-Wolf
01-28-2004, 05:10 PM
yup he did :D i havn't tested the source yet but i will be adding the devc++ changes to it so i can test it =)

Windcatcher
01-28-2004, 05:42 PM
I just downloaded Shawn's CVS and did another merge. One thing to watch for:

In DR2 common\servertalk.h:


// ZONEPROXY BEGIN
#define ServerOP_SetAliasZone 0x002D
// ZONEPROXY END


This causes a conflict in DR3. You should change it to:


// ZONEPROXY BEGIN
#define ServerOP_SetAliasZone 0x0300
// ZONEPROXY END


That should be high enough. From what I can see there should be no difference in any of the other ZP changes. Make sure to pay attention to the ZP change in zone/client_process.cpp where the following line is remarked out for ZP:


//sze->zone_id = zone->GetZoneID();


If someone could show me how to make a diff I can try it tomorrow with what I have. This time I used #ifdefs to keep the original code separate from the ZP stuff...

WC

P.S. There was a bug in line 1511 of zone/spells.cpp from the CVS dump. The variable "ndx" was being redeclared. I had to change it to:

for(ndx=1;ndx<=18;ndx++){

It has nothing to do with ZoneProxy and I had to make this fix before making any ZP changes to DR3.

P.P.S. I just built it and tested a DR3-ZP server and it works just fine. If you do the DR2-ZP changes but make the above change to 0x300 you should be ok. My offer to do a diff still stands though...

farce
01-29-2004, 02:23 AM
here ya go:


diff -r -C 5 53_dr3_orig/common/database.cpp 53_dr3_zp/common/database.cpp
*** 53_dr3_orig/common/database.cpp 2004-01-24 15:30:30.000000000 -0600
--- 53_dr3_zp/common/database.cpp 2004-01-28 14:19:25.000000000 -0600
***************
*** 6114,6123 ****
--- 6114,6177 ----
}
return true;
}
#endif

+ #ifdef ZONEPROXY
+ // Function to return whether a zone is third-party or not. This is so the server knows
+ // whether it needs to use ZoneProxy to swap zones.
+ int8 Database::GetZoneThirdParty(const char* zonename) {
+ char errbuf[MYSQL_ERRMSG_SIZE];
+ char *query = 0;
+ MYSQL_RES *result;
+ MYSQL_ROW row;
+
+ if (RunQuery(query, MakeAnyLenString(&query, "SELECT thirdparty FROM zone WHERE short_name='%s'", zonename), errbuf, &result))
+ {
+ delete[] query;
+ if (mysql_num_rows(result) == 1) {
+ row = mysql_fetch_row(result);
+ int8 tmp = atoi(row[0]);
+ mysql_free_result(result);
+ return tmp;
+ }
+ mysql_free_result(result);
+ }
+
+ else {
+ cerr << "Error in GetZoneThirdParty query '" << query << "' " << errbuf << endl;
+ delete[] query;
+ }
+ return 0;
+ }
+
+ int8 Database::GetZoneThirdPartyByID(int32 zoneid) {
+ char errbuf[MYSQL_ERRMSG_SIZE];
+ char *query = 0;
+ MYSQL_RES *result;
+ MYSQL_ROW row;
+
+ if (RunQuery(query, MakeAnyLenString(&query, "SELECT thirdparty FROM zone WHERE zoneidnumber=%i", zoneid), errbuf, &result))
+ {
+ delete[] query;
+ if (mysql_num_rows(result) == 1) {
+ row = mysql_fetch_row(result);
+ int8 tmp = atoi(row[0]);
+ mysql_free_result(result);
+ return tmp;
+ }
+ mysql_free_result(result);
+ }
+
+ else {
+ cerr << "Error in GetZoneThirdPartyByID query '" << query << "' " << errbuf << endl;
+ delete[] query;
+ }
+ return 0;
+ }
+ #endif
+
//Functions for weather
int8 Database::GetZoneW(int32 zoneid) {
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
MYSQL_RES *result;
diff -r -C 5 53_dr3_orig/common/database.h 53_dr3_zp/common/database.h
*** 53_dr3_orig/common/database.h 2004-01-24 15:30:40.000000000 -0600
--- 53_dr3_zp/common/database.h 2004-01-28 14:20:03.000000000 -0600
***************
*** 180,189 ****
--- 180,193 ----
bool LoadGuildNPCTitles();

typedef pair <int32, char*> GuildInsertPair;
map<int32,char*> GuildNPCs; // NPC IDs and their titles
#endif
+ #ifdef ZONEPROXY
+ int8 GetZoneThirdParty(const char* zonename);
+ int8 GetZoneThirdPartyByID(int32 zoneid);
+ #endif
bool SaveInventory(uint32 char_id, const ItemInst* inst, sint16 slot_id);
bool logevents(char* accountname,int32 accountid,int8 status,const char* charname,const char* target, const char* descriptiontype, const char* description,int event_nid);
bool MoveCharacterToZone(char* charname, char* zonename);
bool MoveCharacterToZone(char* charname, char* zonename,int32 zoneid);
bool MoveCharacterToZone(int32 iCharID, char* iZonename);
diff -r -C 5 53_dr3_orig/common/servertalk.h 53_dr3_zp/common/servertalk.h
*** 53_dr3_orig/common/servertalk.h 2004-01-24 15:31:38.000000000 -0600
--- 53_dr3_zp/common/servertalk.h 2004-01-28 14:23:02.000000000 -0600
***************
*** 56,65 ****
--- 56,66 ----
#define ServerOP_IPLookup 0x002A
#define ServerOP_LockZone 0x002B
#define ServerOP_ItemStatus 0x002C
#define ServerOP_OOCMute 0x002D
#define ServerOP_Revoke 0x002E
+ #define ServerOP_SetAliasZone 0x002F

#define ServerOP_LSInfo 0x1000
#define ServerOP_LSStatus 0x1001
#define ServerOP_LSClientAuth 0x1002
#define ServerOP_LSFatalError 0x1003
***************
*** 399,408 ****
--- 400,415 ----
sint8 response;
sint16 admin;
int8 ignorerestrictions;
};

+ #ifdef ZONEPROXY
+ struct SetAliasZone_Struct {
+ char alias_short_name[40];
+ };
+ #endif
+
struct WorldToZone_Struct {
int32 account_id;
sint8 response;
};
struct WorldShutDown_Struct {
diff -r -C 5 53_dr3_orig/world/client.cpp 53_dr3_zp/world/client.cpp
*** 53_dr3_orig/world/client.cpp 2004-01-18 20:44:10.000000000 -0600
--- 53_dr3_zp/world/client.cpp 2004-01-28 15:38:14.000000000 -0600
***************
*** 42,51 ****
--- 42,54 ----
extern ZSList zoneserver_list;
extern LoginServer loginserver;
extern uint32 numclients;
extern NetConnection net;
extern volatile bool RunLoops;
+ #ifdef ZONEPROXY
+ extern TCPServer tcps;
+ #endif

Client::Client(EQNetworkConnection* ieqnc) {
eqnc = ieqnc;
eqnc->SetDataRate(7);
ip = eqnc->GetrIP();
***************
*** 477,487 ****
}
strncpy(char_name, (char*)app->pBuffer, 64);

APPLAYER *outapp;
int32 tmpaccid = 0;
! charid = database.GetCharacterInfo(char_name, &tmpaccid, &zoneID);
if (charid == 0) {
cerr << "Could not get CharInfo for " << char_name << endl;
eqnc->Close();
break;
}
--- 480,494 ----
}
strncpy(char_name, (char*)app->pBuffer, 64);

APPLAYER *outapp;
int32 tmpaccid = 0;
! long LOCounter;
! do {
! charid = database.GetCharacterInfo(char_name, &tmpaccid, &zoneID);
! LOCounter++;
! }while ((zoneID == 0) && (LOCounter > 10000));
if (charid == 0) {
cerr << "Could not get CharInfo for " << char_name << endl;
eqnc->Close();
break;
}
***************
*** 658,667 ****
--- 665,849 ----
return;
}
}
pwaitingforbootup = 0;

+ #ifdef ZONEPROXY
+ int doAlias = 0;
+ TCPConnection* zoneproxy_out = new TCPConnection(false,&tcps,modeConsole);
+ if (zoneproxy_out->Connect(GetIP(),8800,0))
+ {
+ cout << "Outgoing connection made to ZoneProxy" << endl;
+ char GetAliasZoneName[] = "GetAliasZoneName";
+ zoneproxy_out->Send((unsigned char*)&GetAliasZoneName,16);
+ int tries = 10;
+ char* aliasZoneName = 0;
+ while (tries)
+ {
+ aliasZoneName = zoneproxy_out->PopLine();
+ if (aliasZoneName) tries = 0; else
+ {
+ tries--;
+ Sleep(100);
+ }
+ }
+ if (aliasZoneName)
+ {
+ cout << "Alias zone name: " << aliasZoneName << endl;
+
+ const char* zoneName = database.GetZoneName(zoneID, true);
+ if (database.GetZoneThirdParty(database.GetZoneName(z oneID, true)) ||
+ (strcasecmp(aliasZoneName,zoneName) == 0))
+ {
+ char setZone[] = "SetZone\n";
+ int len = strlen(zoneName);
+ char* setZoneCmd = new char[8 + len];
+ char* cp = setZoneCmd;
+ memcpy(cp,&setZone,8);
+ cp += 8;
+ memcpy(cp,zoneName,len);
+ zoneproxy_out->Send((unsigned char*)setZoneCmd,len + 8);
+
+ // Wait for SettingZone response
+
+ tries = 10;
+ char* response = 0;
+ while (tries)
+ {
+ response = zoneproxy_out->PopLine();
+ if (response) tries = 0; else
+ {
+ tries--;
+ Sleep(100);
+ }
+ }
+ if (response)
+ {
+ char SettingZone[] = "SettingZone";
+
+ if (strcmp(response,SettingZone) == 0)
+ {
+ cout << "Got SettingZone from ZoneProxy" << endl;
+
+ delete response;
+
+ // Wait for DoneSettingZone response
+
+ tries = 300; // Allow up to 30 seconds (10 wasn't enough)
+ while (tries)
+ {
+ response = zoneproxy_out->PopLine();
+ if (response) tries = 0; else
+ {
+ tries--;
+ Sleep(100);
+ }
+ }
+ if (response)
+ {
+ char DoneSettingZone[] = "DoneSettingZone";
+ if (strcmp(response,DoneSettingZone) == 0)
+ {
+ cout << "Got DoneSettingZone from ZoneProxy" << endl;
+
+ zoneproxy_out->Disconnect();
+ delete zoneproxy_out;
+
+ // Tell the zone server what the alias zone name is
+
+ ServerPacket* pack = new ServerPacket;
+ pack->opcode = ServerOP_SetAliasZone;
+ pack->size = sizeof(SetAliasZone_Struct);
+ pack->pBuffer = new uchar[pack->size];
+ memset(pack->pBuffer, 0, pack->size);
+ SetAliasZone_Struct* saz = (SetAliasZone_Struct*) pack->pBuffer;
+ memcpy(saz->alias_short_name,aliasZoneName,strlen(aliasZoneNam e) + 1);
+ zs->SendPacket(pack);
+ delete pack;
+ delete aliasZoneName;
+ delete response;
+ doAlias = 1;
+ }
+ else
+ {
+ cout << "Strange response from ZoneProxy SetZone request: " << response << endl;
+ ZoneUnavail();
+ delete aliasZoneName;
+ zoneproxy_out->Disconnect();
+ delete zoneproxy_out;
+ delete response;
+ return;
+ }
+ }
+ else
+ {
+ cout << "No DoneSettingZone response from ZoneProxy SetZone request" << endl;
+ ZoneUnavail();
+ delete aliasZoneName;
+ zoneproxy_out->Disconnect();
+ delete zoneproxy_out;
+ return;
+ }
+ }
+ else
+ {
+ cout << "Strange response from ZoneProxy SetZone request: " << response << endl;
+ ZoneUnavail();
+ delete aliasZoneName;
+ zoneproxy_out->Disconnect();
+ delete zoneproxy_out;
+ delete response;
+ return;
+ }
+ }
+ else
+ {
+ cout << "No response from ZoneProxy SetZone request" << endl;
+ ZoneUnavail();
+ delete aliasZoneName;
+ zoneproxy_out->Disconnect();
+ delete zoneproxy_out;
+ return;
+ }
+ }
+ else
+ {
+ cout << "Zone " << database.GetZoneName(zoneID, true) << " is NOT third-party" << endl;
+ zoneproxy_out->Disconnect();
+ delete zoneproxy_out;
+ delete aliasZoneName;
+ }
+ }
+ else
+ {
+ cout << "ZoneProxy is running, but we were unable to get the alias zone name" << endl;
+ ZoneUnavail();
+ zoneproxy_out->Disconnect();
+ delete zoneproxy_out;
+ return;
+ }
+ }
+ else
+ {
+ cout << "ZoneProxy not found" << endl;
+ delete zoneproxy_out;
+ }
+ if (!doAlias)
+ {
+ // Tell the zone server that there is no alias zone
+
+ ServerPacket* pack = new ServerPacket;
+ pack->opcode = ServerOP_SetAliasZone;
+ pack->size = sizeof(SetAliasZone_Struct);
+ pack->pBuffer = new uchar[pack->size];
+ memset(pack->pBuffer, 0, pack->size);
+ SetAliasZone_Struct* saz = (SetAliasZone_Struct*) pack->pBuffer;
+ memset(saz->alias_short_name,0,1);
+ zs->SendPacket(pack);
+ delete pack;
+ }
+ #endif
cle->SetChar(charid, char_name);
database.UpdateLiveChar(char_name, GetAccountID());
cout << "Enter world: " << char_name << ": " << database.GetZoneName(zoneID, true) << " (" << zoneID << ")" << endl;
// database.SetAuthentication(account_id, char_name, zone_name, ip);

diff -r -C 5 53_dr3_orig/zone/client.cpp 53_dr3_zp/zone/client.cpp
*** 53_dr3_orig/zone/client.cpp 2004-01-24 15:27:42.000000000 -0600
--- 53_dr3_zp/zone/client.cpp 2004-01-28 13:54:01.000000000 -0600
***************
*** 75,84 ****
--- 75,88 ----
extern int32 numclients;
extern PetitionList petition_list;
bool commandlogged;
char entirecommand[255];

+ #ifdef ZONEPROXY
+ extern char* alias_short_name;
+ #endif
+
#ifdef GUILDWARS
#include "GuildWars.h"
extern GuildWars guildwars;
#endif
#define ITEM_MAX_STACK 20
***************
*** 1253,1266 ****
--- 1257,1293 ----
gms->x = (sint32) x;
gms->y = (sint32) y;
gms->z = (sint32) z;

if (zonename == 0) {
+ #ifdef ZONEPROXY
+ // If this is a third-party zone we need to tell the client the alias zone ID to prevent a zone reload
+ if ((alias_short_name != 0) &&
+ (database.GetZoneThirdPartyByID(zone->GetZoneID())))
+ gms->zoneID = database.GetZoneID(alias_short_name);
+ else
+ #endif
gms->zoneID = zone->GetZoneID();
}
else {
gms->zoneID = database.GetZoneID(zonename);
+ #ifdef ZONEPROXY
+ // Force a zone reload if zoning to the alias zone from a third-party zone
+
+ if ((alias_short_name != 0) &&
+ (gms->zoneID != zone->GetZoneID()) &&
+ (gms->zoneID == database.GetZoneID(alias_short_name)))
+ gms->zoneID = 999;
+
+ // Prevent a zone reload if zoning to a third-party zone from itself
+
+ else if ((alias_short_name != 0) &&
+ (gms->zoneID == zone->GetZoneID()) &&
+ (gms->zoneID != database.GetZoneID(alias_short_name)) &&
+ (database.GetZoneThirdParty(zonename)))
+ gms->zoneID = database.GetZoneID(alias_short_name);
+ #endif
strcpy(zonesummon_name, zonename);
zonesummon_x = x;
zonesummon_y = y;
zonesummon_z = z;
}
***************
*** 1278,1291 ****
--- 1305,1342 ----
gmg->x = (sint32) x;
gmg->y = (sint32) y;
gmg->z = (sint32) z;

if (zonename == 0) {
+ #ifdef ZONEPROXY
+ // If this is a third-party zone we need to tell the client the alias zone ID to prevent a zone reload
+
+ if ((alias_short_name != 0) &&
+ (database.GetZoneThirdPartyByID(zone->GetZoneID())))
+ gmg->zoneID = database.GetZoneID(alias_short_name);
+ else
+ #endif
gmg->zoneID = zone->GetZoneID();
}
else {
gmg->zoneID = database.GetZoneID(zonename);
+ #ifdef ZONEPROXY
+ // Force a zone reload if zoning to the alias zone from a third-party zone
+
+ if ((alias_short_name != 0) &&
+ (gmg->zoneID != zone->GetZoneID()) &&
+ (gmg->zoneID == database.GetZoneID(alias_short_name)))
+ gmg->zoneID = 999;
+
+ // Prevent a zone reload if zoning to a third-party zone from itself
+
+ else if ((alias_short_name != 0) &&
+ (gmg->zoneID == zone->GetZoneID()) &&
+ (gmg->zoneID != database.GetZoneID(alias_short_name)) &&
+ (database.GetZoneThirdParty(zonename)))
+ gmg->zoneID = database.GetZoneID(alias_short_name);
+ #endif
if (gmg->zoneID == 0)
{
Message(0, "Invalid zone name");
safe_delete(outapp);
return;
diff -r -C 5 53_dr3_orig/zone/client.h 53_dr3_zp/zone/client.h
*** 53_dr3_orig/zone/client.h 2004-01-24 15:28:00.000000000 -0600
--- 53_dr3_zp/zone/client.h 2004-01-28 13:55:09.000000000 -0600
***************
*** 55,64 ****
--- 55,67 ----


Client(EQNetworkConnection* ieqnc);
~Client();

+ #ifdef ZONEPROXY
+ int32 GetAppropriateZoneID(const char* zonename);
+ #endif
void Discipline(ClientDiscipline_Struct* disc_in, Mob* tar);
void AI_Init();
void AI_Start(int32 iMoveDelay = 0);
void AI_Stop();
void Trader_ShowItems();
diff -r -C 5 53_dr3_orig/zone/client_process.cpp 53_dr3_zp/zone/client_process.cpp
*** 53_dr3_orig/zone/client_process.cpp 2004-01-24 18:43:44.000000000 -0600
--- 53_dr3_zp/zone/client_process.cpp 2004-01-28 14:09:47.000000000 -0600
***************
*** 80,89 ****
--- 80,93 ----
#endif
extern bool spells_loaded;
extern PetitionList petition_list;
extern EntityList entity_list;

+ #ifdef ZONEPROXY
+ extern char* alias_short_name;
+ #endif
+
int glob=0;

int Client::HandlePacket(const APPLAYER *app)
{
bool ret = true;
***************
*** 1687,1701 ****
--- 1691,1715 ----
z_pos = tarz;
if(tarheading!=999)
m_pp.heading=tarheading;
else
m_pp.heading=heading;
+ #ifdef ZONEPROXY
+ int32 current_zone = database.GetZoneID(target_zone);
+ m_pp.zone_id = database.GetZoneID(target_zone);
+ Save();
+ m_pp.zone_id = GetAppropriateZoneID(target_zone);
+
+ if (current_zone == zone->GetZoneID()) {
+
+ #else
m_pp.zone_id = database.GetZoneID(target_zone);

Save();

if (m_pp.zone_id == zone->GetZoneID()) {
+ #endif
// No need to ask worldserver if we're zoning to ourselves (most
// likely to a bind point), also fixes a bug since the default response was failure
APPLAYER* outapp = new APPLAYER(OP_ZoneChange,sizeof(ZoneChange_Struct));
ZoneChange_Struct* zc2 = (ZoneChange_Struct*) outapp->pBuffer;
strcpy(zc2->char_name, GetName());
***************
*** 1715,1724 ****
--- 1729,1741 ----
ztz->ignorerestrictions = tmpzonesummon_ignorerestrictions;
strcpy(ztz->name, GetName());
worldserver.SendPacket(pack);
safe_delete(pack);
}
+ #ifdef ZONEPROXY
+ m_pp.zone_id = database.GetZoneID(target_zone);
+ #endif
}
else {
LogFile->write(EQEMuLog::Error, "Zone %i is not available", zc->zoneID);

outapp = new APPLAYER(OP_ZoneChange, sizeof(ZoneChange_Struct));
***************
*** 4936,4945 ****
--- 4953,4966 ----
m_pp.cur_hp = GetMaxHP();

SetHP(m_pp.cur_hp);
Mob::SetMana(m_pp.mana);

+ #ifdef ZONEPROXY
+ m_pp.zone_id = GetAppropriateZoneID(zone->GetFileName());
+ #endif
+
m_pp.zone_change_count++;
/*
Unknowns

int bp = 0;
***************
*** 5094,5110 ****
memcpy(outapp->pBuffer,&m_pp,outapp->size);
outapp->Deflate();
QueuePacket(outapp);
safe_delete(outapp);

!
!

////////////////////////////////////////////////////////////
// Server Zone Entry Packet
outapp = new APPLAYER(OP_ZoneEntry, sizeof(ServerZoneEntry_Struct));
ServerZoneEntry_Struct* sze = (ServerZoneEntry_Struct*)outapp->pBuffer;

strcpy(sze->name, m_pp.name);
strcpy(sze->last_name, m_pp.last_name);
sze->gm = m_pp.gm;
sze->race = m_pp.race;
--- 5115,5146 ----
memcpy(outapp->pBuffer,&m_pp,outapp->size);
outapp->Deflate();
QueuePacket(outapp);
safe_delete(outapp);

! #ifdef ZONEPROXY
! m_pp.zone_id = GetAppropriateZoneID(zone->GetShortName());
! #endif

////////////////////////////////////////////////////////////
// Server Zone Entry Packet
outapp = new APPLAYER(OP_ZoneEntry, sizeof(ServerZoneEntry_Struct));
ServerZoneEntry_Struct* sze = (ServerZoneEntry_Struct*)outapp->pBuffer;
+
+ #ifdef ZONEPROXY
+ if (alias_short_name)
+ {
+ cout << "Telling client to load alias zone id: " << database.GetZoneID(alias_short_name) << endl;
+ sze->zone_id = database.GetZoneID(alias_short_name);
+ }
+ else
+ {
+ cout << "Telling client to load zone id: " << zone->GetZoneID() << endl;
+ sze->zone_id = zone->GetZoneID();
+ }
+ m_pp.zone_id = sze->zone_id;
+ #endif

strcpy(sze->name, m_pp.name);
strcpy(sze->last_name, m_pp.last_name);
sze->gm = m_pp.gm;
sze->race = m_pp.race;
sze->class_ = m_pp.class_;
sze->level = m_pp.level;
sze->size = size;
sze->deity = m_pp.deity;
+ #ifndef ZONEPROXY
+ // we dont want to do this for ZoneProxy
sze->zone_id = zone->GetZoneID();
+ #endif
sze->x = m_pp.x;
sze->y = m_pp.y;
sze->z = m_pp.z;
sze->heading = m_pp.heading;
if(sze->heading>0)
***************
*** 5163,5173 ****
memcpy(sze, &crc, 4);
outapp->Deflate();
QueuePacket(outapp);
safe_delete(outapp);

!


////////////////////////////////////////////////////////////
// Zone Spawns Packet
entity_list.SendZoneSpawnsBulk(this);
--- 5199,5211 ----
memcpy(sze, &crc, 4);
outapp->Deflate();
QueuePacket(outapp);
safe_delete(outapp);

! #ifdef ZONEPROXY
! m_pp.zone_id = zone->GetZoneID();
! #endif


////////////////////////////////////////////////////////////
// Zone Spawns Packet
entity_list.SendZoneSpawnsBulk(this);
***************
*** 5207,5216 ****
--- 5245,5263 ----
safe_delete(outapp);
SetAttackTimer();
return true;
}

+ #ifdef ZONEPROXY
+ int32 Client::GetAppropriateZoneID(const char* zonename)
+ {
+ if (database.GetZoneThirdParty(zonename) && alias_short_name)
+ return database.GetZoneID(alias_short_name);
+ else return database.GetZoneID(zonename);
+ }
+ #endif
+
// Finish client connecting state
void Client::CompleteConnect()
{

APPLAYER* outapp;
diff -r -C 5 53_dr3_orig/zone/worldserver.cpp 53_dr3_zp/zone/worldserver.cpp
*** 53_dr3_orig/zone/worldserver.cpp 2004-01-24 15:31:54.000000000 -0600
--- 53_dr3_zp/zone/worldserver.cpp 2004-01-28 14:13:16.000000000 -0600
***************
*** 56,65 ****
--- 56,68 ----
#endif

extern Database database;
extern EntityList entity_list;
extern Zone* zone;
+ #ifdef ZONEPROXY
+ extern char* alias_short_name;
+ #endif
extern volatile bool ZoneLoaded;
extern void CatchSignal(int);
extern WorldServer worldserver;
extern NetConnection net;
extern PetitionList petition_list;
***************
*** 184,193 ****
--- 187,223 ----
wtz->response = 1;

worldserver.SendPacket(pack);
break;
}
+ #ifdef ZONEPROXY
+ case ServerOP_SetAliasZone: {
+
+ cout << "Got ServerOP_SetAliasZone" << endl;
+
+ if(pack->size != sizeof(SetAliasZone_Struct))
+ break;
+ if (!ZoneLoaded)
+ break;
+
+ cout << "Got SetAliasZone_Struct" << endl;
+
+ SetAliasZone_Struct* saz = (SetAliasZone_Struct*) pack->pBuffer;
+ delete[] alias_short_name;
+ if (strlen(saz->alias_short_name) > 0)
+ {
+ alias_short_name = strcpy(new char[strlen(saz->alias_short_name)+1], saz->alias_short_name);
+ cout << "Third-party zone: setting alias zone name to " << alias_short_name << endl;
+ }
+ else
+ {
+ alias_short_name = 0;
+ cout << "Not a third-party zone" << endl;
+ }
+ break;
+ }
+ #endif
case ServerOP_ZoneToZoneRequest: {
if(pack->size != sizeof(ZoneToZone_Struct))
break;
if (!ZoneLoaded)
break;
***************
*** 207,217 ****
--- 237,262 ----
zc2->success = ZONE_ERROR_NOTREADY;
entity->CastToMob()->SetZone(ztz->current_zone_id);
}
else {
strncpy(zc2->char_name,entity->CastToMob()->GetName(),64);
+ #ifdef ZONEPROXY
+ if (alias_short_name)
+ {
+ cout << "Telling client to load alias zone id: " << database.GetZoneID(alias_short_name) << endl;
+
+ zc2->zoneID = database.GetZoneID(alias_short_name);
+ }
+ else
+ {
+ cout << "Telling client to load zone id: " << ztz->requested_zone_id << endl;
+
+ zc2->zoneID=ztz->requested_zone_id;
+ }
+ #else
zc2->zoneID=ztz->requested_zone_id;
+ #endif
zc2->success = 1;
}
if (entity->CastToClient()->isgrouped && entity_list.GetGroupByClient(entity->CastToClient()) != 0){
if(zc2->zoneID!=0)
entity_list.GetGroupByClient(entity->CastToClient())->SendWorldGroup(zc2->zoneID,entity->CastToMob());
diff -r -C 5 53_dr3_orig/zone/zone.cpp 53_dr3_zp/zone/zone.cpp
*** 53_dr3_orig/zone/zone.cpp 2004-01-19 19:51:50.000000000 -0600
--- 53_dr3_zp/zone/zone.cpp 2004-01-28 14:14:20.000000000 -0600
***************
*** 71,80 ****
--- 71,83 ----
extern PetitionList petition_list;
extern EQNetworkServer eqns;
Mutex MZoneShutdown;
extern bool staticzone;
Zone* zone = 0;
+ #ifdef ZONEPROXY
+ char* alias_short_name = 0;
+ #endif
volatile bool ZoneLoaded = false;
extern Parser* parse;
void CleanupLoadZoneState(int32 spawn2_count, ZSDump_Spawn2** spawn2_dump, ZSDump_NPC** npc_dump, ZSDump_NPC_Loot** npcloot_dump, NPCType** gmspawntype_dump, Spawn2*** spawn2_loaded, NPC*** npc_loaded, MYSQL_RES** result);
extern std::list<timers*> TimerList;

Windcatcher
01-29-2004, 09:45 AM
I think you missed a change in your diff. In the original zone/client_process.cpp there is this block of code, starting at line 5107:

strcpy(sze->name, m_pp.name);
strcpy(sze->last_name, m_pp.last_name);
sze->gm = m_pp.gm;
sze->race = m_pp.race;
sze->class_ = m_pp.class_;
sze->level = m_pp.level;
sze->size = size;
sze->deity = m_pp.deity;
sze->zone_id = zone->GetZoneID();
sze->x = m_pp.x;
sze->y = m_pp.y;
sze->z = m_pp.z;
sze->heading = m_pp.heading;
if(sze->heading>0)
sze->heading/=4;

The ZoneProxy version should look like this:

strcpy(sze->name, m_pp.name);
strcpy(sze->last_name, m_pp.last_name);
sze->gm = m_pp.gm;
sze->race = m_pp.race;
sze->class_ = m_pp.class_;
sze->level = m_pp.level;
sze->size = size;
sze->deity = m_pp.deity;


#ifndef ZONEPROXY
// ZONEPROXY BEGIN
// NOTE THE #ifndef above! If compiling for ZoneProxy we DON'T want to do this.

sze->zone_id = zone->GetZoneID();

// ZONEPROXY END
#endif


sze->x = m_pp.x;
sze->y = m_pp.y;
sze->z = m_pp.z;
sze->heading = m_pp.heading;
if(sze->heading>0)
sze->heading/=4;

Note how the line "sze->zone_id = zone->GetZoneID();" does NOT get included if compiling for ZoneProxy.

WC

farce
01-29-2004, 09:55 AM
hrm. well it still seemed to work... i'll check it tho

I updated the original post....