Forum

CSQC ReadEntity

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

CSQC ReadEntity

Postby Urre » Mon Mar 10, 2008 2:53 pm

There's a WriteEntity builtin in ssqc, but no ReadEntity in csqc. Does anyone know how I'm supposed to read WriteEntity calls in CSQC_Ent_Update, or is that perhaps just not possible?
I was once a Quake modder
User avatar
Urre
 
Posts: 1109
Joined: Fri Nov 05, 2004 2:36 am
Location: Moon

Postby Spike » Mon Mar 10, 2008 4:26 pm

ssqc doesn't expose entity numbers to the ssqc, thus it requires a writeentity.
csqc doesn't have access to the ssqc entities, thus a readentity will not always work (if its not known, you would get world, and you would not be able to re-read it).

Entities are sent as shorts, thus to read an entity, call ReadShort. it will return the entity number on the server. This can be matched to the entnum field from entities read from the server.
The ommision is intentional. Any logical behaviour would likely be too unreliable (a ReadEntityNumber builtin would make sense at least, but it would be identical to ReadShort).
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby Urre » Mon Mar 10, 2008 7:40 pm

Ah, well that works for me!
I was once a Quake modder
User avatar
Urre
 
Posts: 1109
Joined: Fri Nov 05, 2004 2:36 am
Location: Moon

Postby Urre » Mon Mar 17, 2008 12:24 pm

I haven't been able to test my code for quite some time, as it's going through quite an overhaul with making everything work in csqc and all, so I'm trying to Do Things Right(tm) from the beginning... One thing that struck me, would this method ever fail? I'm currently having a separate entity with a think function, which assigns entities to the assigned fields on the targeted entity based on edict numbers, as it might not have turned up in csqc yet (packetloss or whatever). That's all fine, but could it possibly ever assign the wrong entity? Could it for some reason get the wrong edict number? Like perhaps, if entities are added/removed?
I was once a Quake modder
User avatar
Urre
 
Posts: 1109
Joined: Fri Nov 05, 2004 2:36 am
Location: Moon

Postby Spike » Mon Mar 17, 2008 5:49 pm

if an entity is removed()ed, there is a 2-second grace period where that entity will not be re-spawn()ed as something else.
So yes, its possible that your entity will come out as something else in extreeme cases, so yes, you should ensure that its the sort of entity that you meant for it to be.
The entity number itself will always be correct, but you may get the wrong instance of that entity number. :P
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby Urre » Tue Mar 18, 2008 2:16 pm

/me curses the grace period

Why does it exist?
I was once a Quake modder
User avatar
Urre
 
Posts: 1109
Joined: Fri Nov 05, 2004 2:36 am
Location: Moon

Postby frag.machine » Tue Mar 18, 2008 11:04 pm

From what I remember to avoid problems with interpolation I guess.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2090
Joined: Sat Nov 25, 2006 1:49 pm


Return to QuakeC Programming

Who is online

Users browsing this forum: Bing [Bot] and 1 guest