Gamestudio Links
Zorro Links
Newest Posts
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
M1 Oversampling
by 11honza11. 04/20/24 20:57
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (rki), 405 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Short unsigned problem #457073
12/23/15 09:10
12/23/15 09:10
Joined: Jan 2006
Posts: 968
EpsiloN Offline OP
User
EpsiloN  Offline OP
User

Joined: Jan 2006
Posts: 968
Code:
rnd = random(400) - 200;
terrainStruct.x = rnd;


The problem is:
rnd = -59;
terrainStruct.x = 64xxx; (or 65xxx?)

rnd is a var, terrainStruct.x is a "short" (also tried "signed short"), but the short overflows (right term?)...

Anyone got any ideas? laugh


EDIT:
I just noticed that the manual shows short range as "0 to 65535", I guess its always unsigned.
I'll try to unsign my pos (subtracting) and store it, then sign upon retrieval, but I've got to find the exact middle value, I guess...

Last edited by EpsiloN; 12/23/15 09:27.

Extensive Multiplayer tutorial:
http://mesetts.com/index.php?page=201
Re: Short unsigned problem [Re: EpsiloN] #457077
12/23/15 12:32
12/23/15 12:32
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
lite-c does not now unsigned afaik but when shorts are always unsigned: WTF? grin


Visit my site: www.masterq32.de
Re: Short unsigned problem [Re: MasterQ32] #457078
12/23/15 12:57
12/23/15 12:57
Joined: Jan 2006
Posts: 968
EpsiloN Offline OP
User
EpsiloN  Offline OP
User

Joined: Jan 2006
Posts: 968
I made a shortcut.
Code:
function unsign_short(x) { return x + 32768; }
function sign_short( short x ) { return x - 32768; }



Here's the problem grin
Manual says:
Quote:

short - 2 bytes - 0 to 65535

And, it also says:
Quote:
Signed or unsigned variables

In lite-C, var, float, double, long and int variables are always signed, and pointers, char and short are always unsigned, according to the normal way they are used. The signed and unsigned variable modifiers are accepted, but have no effect.


Extensive Multiplayer tutorial:
http://mesetts.com/index.php?page=201
Re: Short unsigned problem [Re: EpsiloN] #457079
12/23/15 13:50
12/23/15 13:50
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
Okay, this is quite weird grin


Visit my site: www.masterq32.de
Re: Short unsigned problem [Re: MasterQ32] #457080
12/23/15 14:11
12/23/15 14:11
Joined: Jan 2006
Posts: 968
EpsiloN Offline OP
User
EpsiloN  Offline OP
User

Joined: Jan 2006
Posts: 968
The Weirdness doesn't stop here grin

All of the sudden, this:
Code:
ENTITY* playerEnt = ent_createlocal("bot2.mdl" , posVector , playerEntity );


doesn't attach playerEntity() function to the model!!!

If I cheat it, it works:
Code:
ENTITY* playerEnt = ent_createlocal("bot2.mdl" , posVector , NULL );
playerEntity( playerEnt );


Talk about bugs tongue
I'm feeling desperate now...


Extensive Multiplayer tutorial:
http://mesetts.com/index.php?page=201
Re: Short unsigned problem [Re: EpsiloN] #457083
12/23/15 18:56
12/23/15 18:56
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
Did you set any value to 'dplay_localfunction'?

Re: Short unsigned problem [Re: txesmi] #457084
12/23/15 19:42
12/23/15 19:42
Joined: Jan 2006
Posts: 968
EpsiloN Offline OP
User
EpsiloN  Offline OP
User

Joined: Jan 2006
Posts: 968
No. It should default to 0, meaning actions only on server (but for global entities, not ent_createlocal)

I just dropped my MP project because of a bug(?) with localfunction, I guess.

The manual states, that functions should run on server only, and I based my whole MP Tutorial on that part... I even checked the value (it was 0!)
After I developed most of the gameplay, I realized I was shooting two bullets at the same time from one gun. After further checking (I disabled all client shooting init) it was still shooting one bullet, and the bullet even got the local collision of the server's bullet. I mean, an ent_createlocal-ly created bullet, that SHOULD NOT exist on the server was hitting an entity that existed ONLY on the server grin Talk about bugs...

I'm now fighting to make a full system out of ent_createlocals and all structs. I'll try to avoid using any of the built in stuff, except send_data_to laugh

I even made a custom Collision system for this project grin hahah... But, at least I'm not rendering the screen by myself, yet tongue

Anyway, I'm gonna check the createlocal again, if its attaching a function now, but I guess there is something wrong with how the ent_create and ent_createlocal works with Multiplayer...

EDIT*
I don't know if this sounds stupid, but is it possible, with all my sys_malloc functions, that I'm assigning something to dplay_localfunction by accident, by expanding my struct pointer more than it really is in memory? Just a thought...

Last edited by EpsiloN; 12/23/15 19:44.

Extensive Multiplayer tutorial:
http://mesetts.com/index.php?page=201

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | 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