/* ============ SV_AddGravity ============ */ void SV_AddGravity (edict_t *ent) { float ent_gravity; eval_t *val; val = GetEdictFieldValue(ent, "gravity"); if (val && val->_float) ent_gravity = val->_float; else ent_gravity = 1.0; ent->v.velocity[2] -= ent_gravity * sv_gravity.value * host_frametime; }
eval_t *PR2_GetEdictFieldValue(edict_t *ed, char *field) { char *s; field_t *f; if (!sv_vm) return GetEdictFieldValue(ed, field); for (f = fields; (s = PR2_GetString(f->name)) && *s; f++) if (!strcasecmp(PR2_GetString(f->name), field)) return (eval_t *)((char *) ed + f->ofs); return NULL; }
/* ============ SV_AddGravity ============ */ void SV_AddGravity (edict_t *ent) { float ent_gravity; eval_t *val; val = GetEdictFieldValue(ent, "gravity"); if (val && val->_float) ent_gravity = val->_float; else ent_gravity = 1.0; // Slot Zero 3.50-2 Zero velocity effect. (2 lines) if ((int)ent->v.effects & EF_ZERO_VELOCITY) ent_gravity = 0; ent->v.velocity[2] -= ent_gravity * sv_gravity.value * host_frametime; }
/* ================== SV_Spawn_f ================== */ static void SV_Spawn_f (void) { int i; client_t *client; edict_t *ent; eval_t *val; // Con_Printf("%s\n", __thisfunc__); if (host_client->state != cs_connected) { Con_Printf ("Spawn not valid -- already spawned\n"); return; } // handle the case of a level changing while a client was connecting if ( atoi(Cmd_Argv(1)) != svs.spawncount ) { Con_Printf ("%s from different level\n", __thisfunc__); SV_New_f (); return; } // set up the edict ent = host_client->edict; memset (&ent->v, 0, progs->entityfields * 4); ent->v.colormap = NUM_FOR_EDICT(ent); if (dmMode.integer == DM_SIEGE) ent->v.team = ent->v.siege_team; // FIXME else ent->v.team = 0; // FIXME ent->v.netname = PR_SetEngineString(host_client->name); //ent->v.playerclass = host_client->playerclass = ent->v.next_playerclass = host_client->next_playerclass; ent->v.has_portals = host_client->portals; host_client->entgravity = 1.0; val = GetEdictFieldValue(ent, "gravity"); if (val) val->_float = 1.0; host_client->maxspeed = sv_maxspeed.value; val = GetEdictFieldValue(ent, "maxspeed"); if (val) val->_float = sv_maxspeed.value; // send all current names, colors, and frag counts // FIXME: is this a good thing? SZ_Clear (&host_client->netchan.message); // send current status of all other players for (i = 0, client = svs.clients; i < MAX_CLIENTS; i++, client++) SV_FullClientUpdate (client, &host_client->netchan.message); // send all current light styles for (i = 0; i < MAX_LIGHTSTYLES; i++) { MSG_WriteByte (&host_client->netchan.message, svc_lightstyle); MSG_WriteByte (&host_client->netchan.message, (char)i); MSG_WriteString (&host_client->netchan.message, sv.lightstyles[i]); } // // force stats to be updated // memset (host_client->stats, 0, sizeof(host_client->stats)); MSG_WriteByte (&host_client->netchan.message, svc_updatestatlong); MSG_WriteByte (&host_client->netchan.message, STAT_TOTALSECRETS); MSG_WriteLong (&host_client->netchan.message, PR_GLOBAL_STRUCT(total_secrets)); MSG_WriteByte (&host_client->netchan.message, svc_updatestatlong); MSG_WriteByte (&host_client->netchan.message, STAT_TOTALMONSTERS); MSG_WriteLong (&host_client->netchan.message, PR_GLOBAL_STRUCT(total_monsters)); MSG_WriteByte (&host_client->netchan.message, svc_updatestatlong); MSG_WriteByte (&host_client->netchan.message, STAT_SECRETS); MSG_WriteLong (&host_client->netchan.message, PR_GLOBAL_STRUCT(found_secrets)); MSG_WriteByte (&host_client->netchan.message, svc_updatestatlong); MSG_WriteByte (&host_client->netchan.message, STAT_MONSTERS); MSG_WriteLong (&host_client->netchan.message, PR_GLOBAL_STRUCT(killed_monsters)); // get the client to check and download skins // when that is completed, a begin command will be issued MSG_WriteByte (&host_client->netchan.message, svc_stufftext); MSG_WriteString (&host_client->netchan.message, va("skins\n") ); }
void SV_Spawn_f (void) { int i; client_t *client; edict_t *ent; eval_t *val; int n; if (host_client->state != cs_connected) { Con_Printf ("Spawn not valid -- allready spawned\n"); return; } // handle the case of a level changing while a client was connecting if ( atoi(Cmd_Argv(1)) != svs.spawncount ) { Con_Printf ("SV_Spawn_f from different level\n"); SV_New_f (); return; } n = atoi(Cmd_Argv(2)); // make sure n is valid if ( n < 0 || n > MAX_CLIENTS ) { Con_Printf ("SV_Spawn_f invalid client start\n"); SV_New_f (); return; } // send all current names, colors, and frag counts // FIXME: is this a good thing? SZ_Clear (&host_client->netchan.message); // send current status of all other players // normally this could overflow, but no need to check due to backbuf for (i=n, client = svs.clients + n ; i<MAX_CLIENTS ; i++, client++) SV_FullClientUpdateToClient (client, host_client); // send all current light styles for (i=0 ; i<MAX_LIGHTSTYLES ; i++) { ClientReliableWrite_Begin (host_client, svc_lightstyle, 3 + (sv.lightstyles[i] ? strlen(sv.lightstyles[i]) : 1)); ClientReliableWrite_Byte (host_client, (char)i); ClientReliableWrite_String (host_client, sv.lightstyles[i]); } // set up the edict ent = host_client->edict; memset (&ent->v, 0, progs->entityfields * 4); ent->v.colormap = NUM_FOR_EDICT(ent); ent->v.team = 0; // FIXME ent->v.netname = PR_SetString(host_client->name); host_client->entgravity = 1.0; val = GetEdictFieldValue(ent, "gravity"); if (val) val->_float = 1.0; host_client->maxspeed = sv_maxspeed.value; val = GetEdictFieldValue(ent, "maxspeed"); if (val) val->_float = sv_maxspeed.value; // // force stats to be updated // memset (host_client->stats, 0, sizeof(host_client->stats)); ClientReliableWrite_Begin (host_client, svc_updatestatlong, 6); ClientReliableWrite_Byte (host_client, STAT_TOTALSECRETS); ClientReliableWrite_Long (host_client, pr_global_struct->total_secrets); ClientReliableWrite_Begin (host_client, svc_updatestatlong, 6); ClientReliableWrite_Byte (host_client, STAT_TOTALMONSTERS); ClientReliableWrite_Long (host_client, pr_global_struct->total_monsters); ClientReliableWrite_Begin (host_client, svc_updatestatlong, 6); ClientReliableWrite_Byte (host_client, STAT_SECRETS); ClientReliableWrite_Long (host_client, pr_global_struct->found_secrets); ClientReliableWrite_Begin (host_client, svc_updatestatlong, 6); ClientReliableWrite_Byte (host_client, STAT_MONSTERS); ClientReliableWrite_Long (host_client, pr_global_struct->killed_monsters); // get the client to check and download skins // when that is completed, a begin command will be issued ClientReliableWrite_Begin (host_client, svc_stufftext, 8); ClientReliableWrite_String (host_client, "skins\n" ); }