|
发表于 2008-12-13 21:29:56
|
显示全部楼层
来自 中国–北京–北京–海淀区
回复: 请教个函数fwdAddToFullPack
如果对 edict_t *ent 的entity state已经设置好并要发送至客户端,返回1,否则返回0
state是服务器端保持的一个送至客户端的state info的副本
一个MOD可以调整这个state副本的值使发送至host一个不一样的特殊entity更新。
e和ent就是要更新状态的entity
host就是要收到更新的entity
pset是之前设置的PAS和PVS,我们可以用它让引擎过滤entity
我翻译的也很烂,因为我一直是英语逻辑,从来不把英文翻译过来思考
另外我从来不用资源耗费大户,除了一个serverframe不得不用(amxx用来实现set task)
凡是一些几乎实时更新的函数我从来不hook
这个函数就更频繁了,服务器为了是每个玩家的状态保持同步会不断发送。
另外给你一个entity state这个结构的内容,里面这些值都可以来设置
// Entity state is used for the baseline and for delta compression of a packet of
// entities that is sent to a client.
typedef struct entity_state_s entity_state_t;
struct entity_state_s
{
// Fields which are filled in by routines outside of delta compression
int entityType;
// Index into cl_entities array for this entity.
int number;
float msg_time;
// Message number last time the player/entity state was updated.
int messagenum;
// Fields which can be transitted and reconstructed over the network stream
vec3_t origin;
vec3_t angles;
int modelindex;
int sequence;
float frame;
int colormap;
short skin;
short solid;
int effects;
float scale;
byte eflags;
// Render information
int rendermode;
int renderamt;
color24 rendercolor;
int renderfx;
int movetype;
float animtime;
float framerate;
int body;
byte controller[4];
byte blending[4];
vec3_t velocity;
// Send bbox down to client for use during prediction.
vec3_t mins;
vec3_t maxs;
int aiment;
// If owned by a player, the index of that player ( for projectiles ).
int owner;
// Friction, for prediction.
float friction;
// Gravity multiplier
float gravity;
// PLAYER SPECIFIC
int team;
int playerclass;
int health;
qboolean spectator;
int weaponmodel;
int gaitsequence;
// If standing on conveyor, e.g.
vec3_t basevelocity;
// Use the crouched hull, or the regular player hull.
int usehull;
// Latched buttons last time state updated.
int oldbuttons;
// -1 = in air, else pmove entity number
int onground;
int iStepLeft;
// How fast we are falling
float flFallVelocity;
float fov;
int weaponanim;
// Parametric movement overrides
vec3_t startpos;
vec3_t endpos;
float impacttime;
float starttime;
// For mods
int iuser1;
int iuser2;
int iuser3;
int iuser4;
float fuser1;
float fuser2;
float fuser3;
float fuser4;
vec3_t vuser1;
vec3_t vuser2;
vec3_t vuser3;
vec3_t vuser4;
}; |
|