Note: LucasForums Archive Project
The content here was reconstructed by scraping the Wayback Machine in an effort to restore some of what was lost when LF went down. The LucasForums Archive Project claims no ownership over the content or assets that were archived on archive.org.

This project is meant for research purposes only.

gentity_t vs centity_t

Page: 1 of 1
 JaedenRuiner
07-17-2008, 10:29 AM
#1
Okay,
Well, i've gotten pretty far on everything I've wanted to do, but now I am at a point of evaluation entities on the client side as opposed to the server side. The client side does not use gentity_t structure, it has the centity_t structure. However I'm not quite familiar with the appropriate tests to verify an entity is a client. for gentity_t's on the server side you'd simply do:

if (!ent || !ent->client) {
return;
}
if (ent->s.number > MAX_CLIENTS) {
return;
}


Either of those will tell the code that the current entity isn't a client, you know a real player. On the centity_t side, I have entity that has stored it's owner number. so I'm doing this:

if (ent->s.userInt2 && ent->s.userInt2 <= MAX_CLIENTS) {
centity_t * own = &cg_entities[ent->s.userInt2];
if (!own || !own->client) <----- ERROR. No Client field.

At that point I examined the centity_t structure, and wondered if centity_t :: playerState would be NULL if the entity is NOT a client. Can i test there for player presence to make sure my owner of the entity in question is actually a player/bot/npc, etc?
Thanks
 ensiform
07-17-2008, 6:33 PM
#2
centity_t::currentState::eType will tell you ET_PLAYER vs ET_NPC. but you won't really be able to differentiate vs player/bot unless you come up with some method to communicate it via the scoreboard send method. You should know that centity_t out of your snapshot will be invalid unlike gentity_t which have no knowledge of snapshots. cgs.clientinfo[MAX_CLIENTS] is an array of clients with valid info so, you'd check a pointer to one of those array items and possibly the ::infoValid member as well.
 BobaFettUU
07-19-2008, 8:11 AM
#3
To tell clients from bots apart, here's how UU does it:

Fetch the configstring for the player (get CS_PLAYER + currentstate.number) and see if the infostring has a 'skill' entry. If it does, its a bot, if not, its a human.
 ensiform
07-19-2008, 1:01 PM
#4
Wouldn't do anything if you (like me) had removed support for basejka bots which skill is not even a required key for the CS_PLAYERS info. So I guess ur UU would think all players are humans in my servers. :s
Page: 1 of 1