• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

Connectorcpp segfault

Joined
Apr 3, 2013
Messages
534
Reaction score
108
Sup.

Got stupid error when i'm using the connector cpp library,

Code:
memcpy(res->sPcData[i].awchName, s2ws(this->res->getString("awchName")).c_str(), sizeof(wchar_t)* NTL_MAX_SIZE_CHAR_NAME_UNICODE);

the error come from:

Code:
this->res->getString("awchName")).c_str()

I don't know why when i'm trying to use .c_str() the program crash.

I checked my memory adress and it is not null.
My database containe the table and the field is not empty.

Here's the column propriety:

Code:
`awchName` varchar(14) NOT NULL DEFAULT '',
UNIQUE KEY `idx_username` (`awchName`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COMMENT='Character System';
INSERT INTO `characters` VALUES ('1', '1', 'myfirstchar', '0', '0', '0', '0', '8', '4', '9', '5', '1', '0', '1', '0', '0', '0', '100', '100', 'osef', '0', '0', 'osef', '0');
 
Experienced Elementalist
Joined
Mar 5, 2011
Messages
258
Reaction score
39
You can't just take a UTF 8 String from the database and send it to the client, which requires UTF 16.
 
Joined
Apr 3, 2013
Messages
534
Reaction score
108
omg ..... thanks lol :banghead:



nop change nothing

the crash is not on the client, the crash is when i want to get my string from the database from the server.
 
Last edited:
Dbo Dev
Joined
Sep 19, 2009
Messages
921
Reaction score
191
try not with memcp

try like this
Code:
wcscpy_s(res->sPcData[i].awchName, NTL_MAX_SIZE_CHAR_NAME_UNICODE, s2ws(this->res->getString("awchName")).c_str() );



well for me I have this in charserver

Code:
memcpy(res->sPcData[i].awchName, s2ws(app->db->getString("CharName")).c_str(), sizeof(wchar_t)* NTL_MAX_SIZE_CHAR_NAME_UNICODE);
but works without problems
 
Joined
Apr 3, 2013
Messages
534
Reaction score
108
I think it's the how i insert my charname, i don't specify anything, not the way to get it maybe.



so just finished to remake my create system work fine but skill cannot get my name :?:



if i do:

std::cout << this->res->getString("awchName") << std::endl;

it's shozing me my character name, but if i do this:

std::cout << this->res->getString("awchName").c_str() << std::endl;

it is crshing
:?:


:junglejane: VISUAL
 
Joined
Apr 3, 2013
Messages
534
Reaction score
108
it is not, it is a sql::String



this->res->getString("awchName") return a sql::String

this->res->getString("awchName").c_str() return a const char *



CREATE TABLE `characters` (
`charid` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Identifier',
`AccountID` int(10) DEFAULT '0',
`awchName` varchar(16) DEFAULT '',
PRIMARY KEY (`charid`),
UNIQUE KEY `idx_username` (`awchName`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf16 COMMENT='Character System';

here is my new char database maybe i missed something ?
 
Experienced Elementalist
Joined
Mar 5, 2011
Messages
258
Reaction score
39
I just told you that your database is UTF 8 , and your client requires UTF 16.
Doesn't that tell you anything?
You can't display on client UTF 8. That's what I'm telling you.
 
Back
Top