Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Bug Reports

Development::Bug Reports Post detailed bug reports and what you would like to see next in the emu here.

Reply
 
Thread Tools Display Modes
  #1  
Old 08-01-2015, 09:02 PM
Shendare
Dragon
 
Join Date: Apr 2009
Location: California
Posts: 814
Default Weird MySQL error with #spawn/#npcspawn create

I got the latest code from Github and compiled and copied over, and decided to try out #spawn and #npcspawn create and #npcedit, but I am getting the oddest error when using #spawn and #npcspawn create.

I'll make a hotkey or manually type out the #spawn command:

Quote:
#spawn WoodElf 4 25 0 - 1 0 0 0 0 1
Then manually type out:
Quote:
#npcspawn create
And I'll get the following error in red in my chat window:

Quote:
08-01-2015 :: 17:41:11] [MySQL Error] 1264: Out of range value for column 'sec_melee_type' at row 1
INSERT INTO npc_types (name, level, race, class, hp, gender, texture, helmtexture, size, loottable_id, merchant_id, face, runspeed, prim_melee_type, sec_melee_type) VALUES("WoodElf", 25, 4, 0, 723, 1, 0, 0, 0.000000, 0, 0, 0, 0.000000, 28, -1508384059)
The last value is for a byte, and should be 28 like prim_melee_type, and not just because it's in the spawn struct that way, but because it's actually been -hard coded- that way:

Quote:
zone/npc.cpp - Line 1059-1066

query = StringFormat("INSERT INTO npc_types (name, level, race, class, hp, gender, "
"texture, helmtexture, size, loottable_id, merchant_id, face, "
"runspeed, prim_melee_type, sec_melee_type) "
"VALUES(\"%s\", %i, %i, %i, %i, %i, %i, %i, %f, %i, %i, %i, %f, %i, %i)",
tmpstr, spawn->GetLevel(), spawn->GetRace(), spawn->GetClass(), spawn->GetMaxHP(),
spawn->GetGender(), spawn->GetTexture(), spawn->GetHelmTexture(), spawn->GetSize(),
spawn->GetLoottableID(), spawn->MerchantType, 0, spawn->GetRunspeed(), 28, 28);
auto results = QueryDatabase(query);
How in the world is sec_melee_type getting set to an arbitrary negative int32? I checked and double-checked the number of fields and values being passed, made sure there are as many %s/%i/%f format specifiers as arguments being supplied to StringFormat, and I'm just scratching my head.

I tried it both without (above) and with (below) the #npcspawn create extra parameter of 1:

Quote:
[08-01-2015 :: 18:05:01] [MySQL Error] 1264: Out of range value for column 'sec_melee_type' at row 1
INSERT INTO npc_types (id, name, level, race, class, hp, gender, texture, helmtexture, size, loottable_id, merchant_id, face, runspeed, prim_melee_type, sec_melee_type) VALUES(54308, "WoodElf" , 25, 4, 0, 723, 1, 0, 0, 0.000000, 0, 0, 0, 0.000000, 28, -1508384059)
Anybody have an idea?
Reply With Quote
  #2  
Old 08-01-2015, 11:39 PM
Kingly_Krab
Administrator
 
Join Date: May 2013
Location: United States
Posts: 1,589
Default

Spawn works like this:
Code:
#spawn [name] [race] [level] [material] [hp] [gender] [class] [priweapon] [secweapon] [merchantid]
You're doing #spawn WoodElf 4 25 0 - 1 0 0 0 0 1
So "WoodElf" Name, Wood Elf Race, Level 25, 0 Material, - Hp, 1 Gender, 0 class, 0 Primary, 0 Secondary, 1 Merchant ID.
Reply With Quote
  #3  
Old 08-02-2015, 12:51 AM
Shendare
Dragon
 
Join Date: Apr 2009
Location: California
Posts: 814
Default

That's close, but #spawn help is saying:

Quote:
Format: #spawn name race level material hp gender class priweapon secweapon merchantid bodytype
The only difference is bodytype at the end. You missed a 0 between that and gender 1. I seem to be feeding the parameters correctly.

I thought maybe class 0 was the problem, since there is no class 0, but changing it to 1 for warrior didn't make a difference.
Reply With Quote
  #4  
Old 08-02-2015, 01:12 AM
Kingly_Krab
Administrator
 
Join Date: May 2013
Location: United States
Posts: 1,589
Default

Regardless, an additional parameter is not the issue. You're passing the minus symbol (-) as the value for hp, which could be an issue. I know I don't have any issues making NPCs.
Reply With Quote
  #5  
Old 08-02-2015, 01:33 AM
Shendare
Dragon
 
Join Date: Apr 2009
Location: California
Posts: 814
Default

The minus symbol tells it to calculate the NPC's MaxHP based on its level. It's calculating it to 723, so that feature's working okay.

I'm experimenting with StringFormat and MessageBox now, to figure out when the last arg changes from 28 to an arbitrary value.

You know what the weird thing is? I changed the affected line in the source (npc.cpp line 1052) from:

Quote:
spawn->MerchantType, 0, spawn->GetRunspeed(), 28, 28);
...to:

Quote:
spawn->MerchantType, 0, spawn->GetRunspeed(), 28, 28, 0);
The query runs as:

Quote:
INSERT INTO npc_types (id, name, level, race, class, hp, gender, texture, helmtexture, size, loottable_id, merchant_id, face, runspeed, prim_melee_type, sec_melee_type) VALUES(54308, "WoodElf" , 25, 4, 0, 723, 1, 0, 0, 0.000000, 0, 0, 0, 0.000000, 28, 0)
And when I change the line to:

Quote:
spawn->MerchantType, 0, spawn->GetRunspeed(), 28, 28, 28);
...it gets run successfully as:

Quote:
INSERT INTO npc_types (id, name, level, race, class, hp, gender, texture, helmtexture, size, loottable_id, merchant_id, face, runspeed, prim_melee_type, sec_melee_type) VALUES(54308, "WoodElf" , 25, 4, 0, 723, 1, 0, 0, 0.000000, 0, 0, 0, 0.000000, 28, 28)
Something funky is going on after that first 28. It's skipping over an argument after it.
Reply With Quote
  #6  
Old 08-02-2015, 01:52 AM
Shendare
Dragon
 
Join Date: Apr 2009
Location: California
Posts: 814
Default

Through chatting, KK and I figured out that the code is trying to pass GetRunSpeed() as a float in the format string ("%f"), when it's actually an integer, and my Visual Studio 2013 is b0rking at that mismatch.

Changing that %f to %i in both query format strings fixes the problem. Too weird.
Reply With Quote
  #7  
Old 08-02-2015, 02:22 AM
Shendare
Dragon
 
Join Date: Apr 2009
Location: California
Posts: 814
Default

A couple more glitches in #npc create are causing problems.

spawngroupid and npc_type_id aren't being set in the spawn struct when they're created in the database, so the values for those in the Mob class are zeroes.

Fixes with these three new lines:

zone/npc.cpp:
Quote:
@@ -1076,6 +1076,9 @@ uint32 ZoneDatabase::CreateNewNPCCommand(const char *zone, uint32 zone_version,
return false;
}
uint32 spawngroupid = results.LastInsertedID();

+ spawn->SetSp2(spawngroupid);
+ spawn->SetNPCTypeID(npc_type_id);

query = StringFormat("INSERT INTO spawn2 (zone, version, x, y, z, respawntime, heading, spawngroupID) "
"VALUES('%s', %u, %f, %f, %f, %i, %f, %i)",
zone/mob.h
Quote:
@@ -431,6 +431,7 @@ public:
((static_cast<float>(cur_mana) / max_mana) * 100); }
virtual int32 CalcMaxMana();
uint32 GetNPCTypeID() const { return npctype_id; }
+ void SetNPCTypeID(uint32 npctypeid) { npctype_id = npctypeid; }
inline const glm::vec4& GetPosition() const { return m_Position; }
inline const float GetX() const { return m_Position.x; }
inline const float GetY() const { return m_Position.y; }
Reply With Quote
  #8  
Old 08-02-2015, 03:48 AM
Shendare
Dragon
 
Join Date: Apr 2009
Location: California
Posts: 814
Default

And all fixed. Akkadius is the man.

https://github.com/EQEmu/Server/comm...122fd954d35b4b
Reply With Quote
Reply


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:40 PM.


 

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 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3