/* * G_SnapFrame * It's time to send a new snap, so set the world up for sending */ void G_SnapFrame( void ) { edict_t *ent; game.realtime = trap_Milliseconds(); // level.time etc. might not be real time //others G_UpdateServerInfo(); // exit level if( level.exitNow ) { G_ExitLevel(); return; } AITools_Frame(); //MbotGame //give think time to AI debug tools // finish snap G_SnapClients(); // build the playerstate_t structures for all players G_SnapEntities(); // add effects based on accumulated info along the frame // set entity bits (prepare entities for being sent in the snap) for( ent = &game.edicts[0]; ENTNUM( ent ) < game.numentities; ent++ ) { if( ent->s.number != ENTNUM( ent ) ) { if( developer->integer ) G_Printf( "fixing ent->s.number (etype:%i, classname:%s)\n", ent->s.type, ent->classname ? ent->classname : "noclassname" ); ent->s.number = ENTNUM( ent ); } // temporary filter (Q2 system to ensure reliability) // ignore ents without visible models unless they have an effect if( !ent->r.inuse ) { ent->r.svflags |= SVF_NOCLIENT; continue; } else if( ent->s.type >= ET_TOTAL_TYPES || ent->s.type < 0 ) { if( developer->integer ) G_Printf( "'G_SnapFrame': Inhibiting invalid entity type %i\n", ent->s.type ); ent->r.svflags |= SVF_NOCLIENT; continue; } else if( !( ent->r.svflags & SVF_NOCLIENT ) && !ent->s.modelindex && !ent->s.effects && !ent->s.sound && !ISEVENTENTITY( &ent->s ) && !ent->s.light && !ent->r.client ) { if( developer->integer ) G_Printf( "'G_SnapFrame': fixing missing SVF_NOCLIENT flag (no effect)\n" ); ent->r.svflags |= SVF_NOCLIENT; continue; } ent->s.effects &= ~EF_TAKEDAMAGE; if( ent->takedamage ) ent->s.effects |= EF_TAKEDAMAGE; if( GS_MatchPaused() ) { // when in timeout, we don't send entity sounds entity_sound_backup[ENTNUM( ent )] = ent->s.sound; ent->s.sound = 0; } } }
/* ================ G_RunFrame Advances the world by 0.1 seconds ================ */ void G_RunFrame (void) { int i; edict_t *ent; level.framenum++; level.time = level.framenum*FRAMETIME; // choose a client for monsters to target this frame AI_SetSightClient (); // exit intermissions if (level.exitintermission) { ExitLevel (); return; } // // treat each object in turn // even the world gets a chance to think // ent = &g_edicts[0]; for (i=0 ; i<globals.num_edicts ; i++, ent++) { if (!ent->inuse) continue; level.current_entity = ent; VectorCopy (ent->s.origin, ent->s.old_origin); // if the ground entity moved, make sure we are still on it if ((ent->groundentity) && (ent->groundentity->linkcount != ent->groundentity_linkcount)) { ent->groundentity = NULL; if ( !(ent->flags & (FL_SWIM|FL_FLY)) && (ent->svflags & SVF_MONSTER) ) { M_CheckGround (ent); } } if (i > 0 && i <= maxclients->value) { ClientBeginServerFrame (ent); //JABot[start] if( !ent->ai ) //jabot092(2) //[end] continue; } G_RunEntity (ent); } // see if it is time to end a deathmatch CheckDMRules (); // build the playerstate_t structures for all players ClientEndServerFrames (); //JABot[start] AITools_Frame(); //give think time to AI debug tools //[end] }