Gamestudio Links
Zorro Links
Newest Posts
Z9 getting Error 058
by madpower2000. 07/22/26 14:01
ZorroGPT
by TipmyPip. 07/21/26 17:54
New Zorro version 3.11
by jcl. 07/21/26 13:42
Lapsa's very own thread
by Lapsa. 07/18/26 13:40
Purchase A8 full licence version
by ukgamer. 07/17/26 05:52
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
6 registered members (AndrewAMD, madpower2000, Quad, VoroneTZ, TipmyPip, 1 invisible), 1,674 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
riggi89, shuhari, KD1990, Ephraim, Student_64151
19223 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: STRING* and external plugins [Re: Lukas] #323759
05/17/10 08:58
05/17/10 08:58
Joined: Jul 2000
Posts: 28,126
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,126
Frankfurt
I am not aware of any 7.84 incompatibility - at least your example works just as before with the latest version. Your problem might be something ANET specific. But you should be able to determine this easily: just check the STRING content in the C++ debugger and then you can see what goes wrong on its way after the function call.

With Unicode, there was indeed a bug - it's fixed in a minor update that you can download here:

http://server.conitec.net/down/gstudio_7843.exe

However, this probably won't affect you when you're not using Unicode in ANET. Your example is ASCII, not Unicode.



Re: STRING* and external plugins [Re: jcl] #323922
05/18/10 12:38
05/18/10 12:38
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline OP
Serious User
Dark_samurai  Offline OP
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
Thanks for your answer!

I did some more tests: The problem only occures with overloaded functions.

Example:

Lite-C:
Code:
void exSample_function(STRING* str);
void exSample_function(char* str) {exSample_function(_str(str));}

void main()
{
   STRING* test_str = str_create("#10");
   str_cpy(test_str,"TEST");
   exSample_function(test_str);
}



C++:
Code:
DLLFUNC void exSample_function(STRING* str)
{
   char str_as_char[10];

   strcpy(str_as_char,str->chars);
   //str_as_char is NOT filled with the correct content
   //only with random symbols
}



str_as_char is filled with wrong content now (checked with the C++ Debugger). This worked with A7.82. After removing the char* prototype it works as before.

And another thing I came over:

If I'm calling a function:

Code:
exSample_function("");



C++:
Code:
void exSample_function(STRING* teststr)
{
   if(strlen(_CHR(password)) > 0) //causes a crash now
}



Causes a crash because password is not an empty string but an empty pointer. Worked in A7.82 also.


ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Re: STRING* and external plugins [Re: Dark_samurai] #323937
05/18/10 13:51
05/18/10 13:51
Joined: Jul 2000
Posts: 28,126
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,126
Frankfurt
Ok, I see problems in that code that most likely explain the crashes.

"" is not a STRING. It's just a char* pointer pointing to a 0 byte. This is C/C++ standard. I suppose your _CHR function can not handle this and crashes.

For converting a STRING* to a char*, just use the proper conversion:

http://manual.3dgamestudio.net/_chr.htm

This won't crash.

Overloading won't do because engine functions make no difference between char* and STRING*. Otherwise, users had to overload all their STRING* functions - I think most would not like that.




Re: STRING* and external plugins [Re: jcl] #323945
05/18/10 15:02
05/18/10 15:02
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline OP
Serious User
Dark_samurai  Offline OP
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
_CHR is a Macro from the SDK not a function I made:

adll.h:
Code:
inline char* _CHR(STRING* s) { return s->chars; }			// STRING* -> char



But you're right it crashes because I'm passing a char* instead of a STRING*. It works if I convert the char* to a STRING* with _str("").

Quote:

Overloading won't do because engine functions make no difference between char* and STRING*. Otherwise, users had to overload all their STRING* functions - I think most would not like that.


So that behavior was changed since A7.82? Because with A7.82 everything went out fine...

Is this the correct way how it should be done?

Lite-C:
Code:
void exSample_function(STRING* str);

void main()
{
   STRING* test_str = str_create("#10");
   str_cpy(test_str,"TEST");
   exSample_function(test_str);
   exSample_function("Blabla"); //works also with char now
}



C++:
Code:
void exSample_function(STRING* str)
{
   char* temp_str;

   temp_str = _chr(str);
}




ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Re: STRING* and external plugins [Re: Dark_samurai] #324054
05/19/10 11:02
05/19/10 11:02
Joined: Jul 2000
Posts: 28,126
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,126
Frankfurt
Yes, that's perfect - our own plugins are also doing it this way.

There was indeed something changed with overloaded functions in 7.84, which might have been the reason that it worked in the version before.

Re: STRING* and external plugins [Re: jcl] #324351
05/20/10 13:46
05/20/10 13:46
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline OP
Serious User
Dark_samurai  Offline OP
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
Thanks for the info!

Edit:
"the char* string must be null-terminated and contain at least 3 characters"

And what is with char* strings with less then 3 characters? It's required that those are also supported...

Last edited by Dark_samurai; 05/20/10 13:52.

ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Re: STRING* and external plugins [Re: Dark_samurai] #325388
05/26/10 11:48
05/26/10 11:48
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline OP
Serious User
Dark_samurai  Offline OP
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
Quote:

"the char* string must be null-terminated and contain at least 3 characters"

And what is with char* strings with less then 3 characters? It's required that those are also supported...


Any chance that this limtation will be changed?


ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Re: STRING* and external plugins [Re: Dark_samurai] #325390
05/26/10 12:01
05/26/10 12:01
Joined: Jul 2000
Posts: 28,126
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,126
Frankfurt
Don't worry, it also works with 0, 1, and 2 characters.

The memory space allocated for the string must be at least 4 bytes, but all compilers normally allocate memory on dword boundaries, so this is automatically fulfilled.

Re: STRING* and external plugins [Re: jcl] #325408
05/26/10 13:25
05/26/10 13:25
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline OP
Serious User
Dark_samurai  Offline OP
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
Ok that's great!

Thanks!


ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Page 2 of 2 1 2

Moderated by  old_bill, Tobias 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1