Jump to content

Home

gentity_t vs centity_t


JaedenRuiner

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...