Go Back   EQEmulator Home > EQEmulator Forums > Archives > Archive::Development > Archive::Development

Archive::Development Archive area for Development's posts that were moved here after an inactivity period of 90 days.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 09-11-2004, 09:37 AM
RangerDown
Demi-God
 
Join Date: Mar 2004
Posts: 1,066
Default #spawnfix -- fixed!

The #spawnfix command in its current implementation has some shortcomings. Main one being that it tries to search the spawn2 database based on the mob's current x,y,z,heading - which means that
(1) if the mob starts moving or turns to face another direction, you can't use #spawnfix after that
(2) because of imprecision in the way floats are saved to the database, you effectively get to use #spawnfix ONCE per mob, and after that it will give you the "duplicate spawns detected" if you ever try to fix that same mob spawn again.

This rewritten #spawnfix command gets rid of those limitations by using the mob's spawn ID number from the database, instead of trying to query based on the mob's current position.

In zone/command.cpp, seek to where the "command_spawnfix" function is defined. Remove it completely, and replace it with this function:

Code:
void command_spawnfix(Client *c, const Seperator *sep)
{
	Mob *t = c->GetTarget();
	if (!t || !t->IsNPC())
		c->Message(0, "Error: #spawnfix: Need an NPC target.");
	else {
		Spawn2* s2 = t->CastToNPC()->respawn2;
		char errbuf[MYSQL_ERRMSG_SIZE];
		char *query = 0;

		if(!s2)
		{   c->Message(0, "#spawnfix FAILED -- cannot determine which spawn entry in the database this mob came from.");
		}
		else
		{   if(database.RunQuery(query, MakeAnyLenString(&query, "UPDATE spawn2 SET x='%f', y='%f', z='%f', heading='%f' WHERE id='%i'",c->GetX(), c->GetY(), c->GetZ(), c->GetHeading(),s2->GetID()), errbuf))
		    {	c->Message(0, "Updating coordinates successful.");
			t->Depop(false);
		    }
		    else
		    {	c->Message(13, "Update failed! MySQL gave the following error:");
			c->Message(13, errbuf);
		    }
		    safe_delete_array(query);
		}
	}
}
__________________
<idleRPG> Rogean ate a plate of discounted, day-old sushi. This terrible calamity has slowed them 0 days, 15:13:51 from level 48.
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 07:47 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3