View Single Post
  #5  
Old 06-09-2008, 08:09 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Looks like many of the doors for the later expansions (using dreadspire as an example) are more than 16 characters. This may also be the case for other objects as well. But, I am only focusing on doors at this point.

So, I changed my table design to use 32 max characters for the door name field. And, it still wasn't working, so I started looking at the source and saw that it was set to 16 in many places there as well.

Every case that I found 16 set for door names, I changed it. After the following changes, all doors were gone when I started the server, so it must have messed something up lol. Here are the changes I made.

All code changes are marked in red:

zone/doors.cpp:
Code:
Doors::Doors(const Door* door)
:    close_timer(5000)
{
	db_id = door->db_id;
	door_id = door->door_id;
	strncpy(zone_name,door->zone_name,16);
	strncpy(door_name,door->door_name,32);

Code:
	if (RunQuery(query, strlen(query), errbuf, &result)) {
		safe_delete_array(query);
		sint32 r;
		for(r = 0; (row = mysql_fetch_row(result)); r++) {
			if(r >= iDoorCount) {
				cerr << "Error, Door Count of " << iDoorCount << " exceeded." << endl;
				break;
			}
			memset(&into[r], 0, sizeof(Door));
			into[r].db_id = atoi(row[0]);
			into[r].door_id = atoi(row[1]);
			strncpy(into[r].zone_name,row[2],16);
			strncpy(into[r].door_name,row[3],32);


zone/doors.h:

Code:
private:
int32	db_id;
sint8	door_id;
char	zone_name[16];
char	door_name[32];

zone/entity.cpp:

Code:
bool EntityList::MakeDoorSpawnPacket(EQApplicationPacket* app)
{
	int32 count = door_list.Count();
	if( !count || count>500)
		return false;
	int32 length = count * sizeof(Door_Struct);
	uchar* packet_buffer = new uchar[length];
	memset(packet_buffer, 0, length);
	uchar* ptr = packet_buffer;
	Doors *door;
	LinkedListIterator<Doors*> iterator(door_list);
	Door_Struct nd;
	iterator.Reset();
	while(iterator.MoreElements()){
		door = iterator.GetData();
		if(door && strlen(door->GetDoorName()) > 3){
			memset(&nd, 0, sizeof(nd));
			memcpy(nd.name, door->GetDoorName(), 32);

common/dbsharemem.cpp:

Code:
			max_door_type = atoi(row[0]);
			mysql_free_result(result);
			Door tmpDoor;
				MakeAnyLenString(&query, "SELECT id,doorid,zone,name,pos_x,pos_y,pos_z,heading,opentype,guild,lockpick,keyitem,triggerdoor,triggertype from doors");//WHERE zone='%s'", zone_name
				if (RunQuery(query, strlen(query), errbuf, &result))
				{
					safe_delete(query);
					while((row = mysql_fetch_row(result))) {
						memset(&tmpDoor, 0, sizeof(Door));
						tmpDoor.db_id = atoi(row[0]);
						tmpDoor.door_id = atoi(row[1]);
						strncpy(tmpDoor.zone_name,row[2],16);
						strncpy(tmpDoor.door_name,row[3],32); //was set to 10 previously

common/eq_packet_structs.h:

Code:
struct Door_Struct
{
/*0000*/ char    name[32];            // Filename of Door // Was 10char long before... added the 6 in the next unknown to it: Daeken M. BlackBlade //changed both to 32: Trevius

utils/schema.xml:

Code:
<TABLE ID="4543" Tablename="doors" PrevTableName="" XPos="2108" YPos="2375" TableType="0" TablePrefix="0" nmTable="0" Temporary="0" UseStandardInserts="0" StandardInserts="" TableOptions="" Comments="" Collapsed="0" IsLinkedObject="0" IDLinkedModel="-1" Obj_id_Linked="-1" OrderPos="14" >
<COLUMNS>
<COLUMN ID="4906" ColName="id" PrevColName="" Pos="1" idDatatype="5" DatatypeParams="(11)" Width="0" Prec="0" PrimaryKey="1" NotNull="1" AutoInc="0" IsForeignKey="0" DefaultValue="" Comments="">
<OPTIONSELECTED>
<OPTIONSELECT Value="0" />
<OPTIONSELECT Value="0" />
</OPTIONSELECTED>
</COLUMN>
<COLUMN ID="4907" ColName="doorid" PrevColName="" Pos="2" idDatatype="2" DatatypeParams="(4)" Width="0" Prec="0" PrimaryKey="0" NotNull="1" AutoInc="0" IsForeignKey="0" DefaultValue="" Comments="">
<OPTIONSELECTED>
<OPTIONSELECT Value="0" />
<OPTIONSELECT Value="0" />
</OPTIONSELECTED>
</COLUMN>
<COLUMN ID="4908" ColName="zone" PrevColName="" Pos="3" idDatatype="20" DatatypeParams="(16)" Width="0" Prec="0" PrimaryKey="0" NotNull="1" AutoInc="0" IsForeignKey="1" DefaultValue="" Comments="">
<OPTIONSELECTED>
<OPTIONSELECT Value="0" />
</OPTIONSELECTED>
</COLUMN>
<COLUMN ID="4909" ColName="name" PrevColName="" Pos="4" idDatatype="20" DatatypeParams="(32)" Width="0" Prec="0" PrimaryKey="0" NotNull="1" AutoInc="0" IsForeignKey="0" DefaultValue="" Comments="">

zone/zonedump.h:

Code:
struct Door {
int32	db_id;
int8	door_id;
char	zone_name[16];
char	door_name[32];

common/patches/anniversary_structs.h:

Code:
struct Door_Struct
{
/*0000*/ char    name[32];            // Filename of Door // Was 10char long before... added the 6 in the next unknown to it: Daeken M. BlackBlade // changed to 32: Trevius

common/patches/client62_structs.h:
Code:
struct Door_Struct
{
/*0000*/ char    name[32];            // Filename of Door // Was 10char long before... added the 6 in the next unknown to it: Daeken M. BlackBlade // changed to 32: Trevius

common/patches/live_structs.h

Code:
struct Door_Struct
{
/*0000*/ char    name[32];            // Filename of Door // Was 10char long before... added the 6 in the next unknown to it: Daeken M. BlackBlade // changed to 32: Trevius

common/patches/titanium_structs.h

Code:
struct Door_Struct
{
/*0000*/ char    name[32];            // Filename of Door // Was 10char long before... added the 6 in the next unknown to it: Daeken M. BlackBlade // changed to 32: Trevius
So, I must have made some change that caused the doors to disapear. I will look into this more tomorrow, but if anyone can help out with fixing this, it would be appreciated! I plan to add in a Server Code Submission for this when it is done so it can get added to the source. If anyone else helps, they will get credit of course. I also plan to add this into my source and will post the completed source with these changes and the previous ones I have posted.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote