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.

Reply
 
Thread Tools Display Modes
  #1  
Old 01-05-2003, 06:24 PM
mByte
Hill Giant
 
Join Date: Feb 2002
Posts: 206
Default strncpy question

I am working on a small side project for me to add npc's just by being in the world.

I am saving them to the database but now I want to remove the 000's

can somebody over look this code tell me what is wrong and someway to fix it.

Code:
void Database::SaveSpawn(const char* s1, int8 s2, int16 s3, int8 s4, sint32 s5, int8 s6, int8 s7, int8 s8, float s9, int8 s10)
{
	char errbuf[MYSQL_ERRMSG_SIZE];
	int snl = strlen(s1)-3;
	char snbuff[64];
	char *query = 0;
	int32 affected_rows = 0;
    MYSQL_RES *result;
    MYSQL_ROW row;

	if(strstr(s1, "00") != 0){
		strncpy(snbuff,s1,snl);
	}

	char* sqlQuery = "INSERT INTO npc_types (name, level, race, class, hp, gender, texture, helmtexture, size, social) values('%s','%i','%i','%i','%i','%i','%i','%i','%f','%i')";

	RunQuery(query, MakeAnyLenString(&query, sqlQuery, snbuff,s2,s3,s4,s5,s6,s7,s8,s9,s10));
	delete[] query;
}
npc name being passed is 'hot000'

It is removing the three 000's but replacing with this other crap any tips?
[code]
hot
__________________
mByte
Reply With Quote
  #2  
Old 01-05-2003, 06:33 PM
Joolz
Fire Beetle
 
Join Date: Jan 2003
Posts: 25
Default

The 000's MUST be there. Well it should be 00 (Hogie changed it in the next release). Never remove them. Otherwise, things won't work properly. (Like horses etc.)
Reply With Quote
  #3  
Old 01-05-2003, 07:00 PM
mByte
Hill Giant
 
Join Date: Feb 2002
Posts: 206
Default

Yea,I understand that but when you put them in the NPC_TYPES table you do not need 000's the 00's are added by the emulator and client or you would need to have a shit load of the same spawn records there for defeting the pourpse of a database.

I dont want to remove them from the game just the record i am putting into the database from walking around the zone!

ontop of that the question was is there a way to fix my problem its in no way part of the release that hoggie and all the awsome dev's do. Just a simple function I want to use.
__________________
mByte
Reply With Quote
  #4  
Old 01-05-2003, 11:49 PM
Joolz
Fire Beetle
 
Join Date: Jan 2003
Posts: 25
Default

Then just do snbuff[snl] = 0;
Reply With Quote
  #5  
Old 01-06-2003, 01:09 PM
mByte
Hill Giant
 
Join Date: Feb 2002
Posts: 206
Default

Spank You!

I kept trying to do it
char snbuffer[snl]; and it wasnt working now i know why

*I learn something new everyday*
__________________
mByte
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 06:05 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 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3