/** * @sa SV_RunGameFrame * @sa G_MatchEndTrigger * @sa AI_Run * @return true if game reaches its end - false otherwise */ static bool G_RunFrame (void) { level.framenum++; /* server is running at 10 fps */ level.time = level.framenum * SERVER_FRAME_SECONDS; /* this doesn't belong here, but it works */ if (!level.routed) { level.routed = true; G_CompleteRecalcRouting(); } /* still waiting for other players */ if (!G_MatchIsRunning()) { if (sv_maxteams->modified) { /* inform the client */ gi.ConfigString(CS_MAXTEAMS, "%i", sv_maxteams->integer); sv_maxteams->modified = false; } } if (G_IsMultiPlayer()) { if (sv_roundtimelimit->modified) { /* some played around here - restart the count down */ level.roundstartTime = level.time; /* don't allow smaller values here */ if (sv_roundtimelimit->integer < 30 && sv_roundtimelimit->integer > 0) { gi.DPrintf("The minimum value for sv_roundtimelimit is 30\n"); gi.Cvar_Set("sv_roundtimelimit", "30"); } sv_roundtimelimit->modified = false; } G_CheckForceEndRound(); } /* end this game? */ if (G_MatchDoEnd()) return true; CheckNeedPass(); /* run ai */ AI_Run(); /* not all teams are spawned or game has already ended */ if (G_MatchIsRunning()) G_EdictsThink(); G_SendBoundingBoxes(); return false; }
static void testMoveEntities (void) { pos3_t pos; vec3_t vec; pathing_t* path = Mem_AllocType(pathing_t); forbiddenList_t forbiddenList; const byte crouchingState = 0; const int maxTUs = MAX_ROUTE_TUS; forbiddenList.reset(); SV_Map(true, mapName, nullptr); /* starting point */ VectorSet(vec, 240, -144, 32); VecToPos(vec, pos); G_CompleteRecalcRouting(); { Edict* ent = nullptr; while ((ent = G_EdictsGetNextInUse(ent))) { /* Dead 2x2 unit will stop walking, too. */ if (ent->type == ET_SOLID) { int j; for (j = 0; j < ent->forbiddenListSize; j++) { forbiddenList.add(ent->forbiddenListPos[j], (byte*) &ent->fieldSize); } } } } { int lengthStored; pos3_t to; Grid_CalcPathing(sv->mapData.routing, ACTOR_SIZE_NORMAL, path, pos, maxTUs, &forbiddenList); Grid_MoveStore(path); /* walk onto the func_breakable */ { VectorSet(vec, 112, -144, 32); VecToPos(vec, to); lengthStored = Grid_MoveLength(path, to, crouchingState, true); CU_ASSERT_EQUAL(lengthStored, 4 * TU_MOVE_STRAIGHT); } /* walk over the func_breakable */ { VectorSet(vec, 80, -144, 32); VecToPos(vec, to); lengthStored = Grid_MoveLength(path, to, crouchingState, true); CU_ASSERT_EQUAL(lengthStored, 5 * TU_MOVE_STRAIGHT); } /* walk over the func_breakable */ { VectorSet(vec, 16, -144, 32); VecToPos(vec, to); lengthStored = Grid_MoveLength(path, to, crouchingState, true); CU_ASSERT_EQUAL(lengthStored, 7 * TU_MOVE_STRAIGHT); } } /* starting point */ VectorSet(vec, 144, 144, 32); VecToPos(vec, pos); { int lengthStored; pos3_t to; Grid_CalcPathing(sv->mapData.routing, ACTOR_SIZE_NORMAL, path, pos, maxTUs, &forbiddenList); Grid_MoveStore(path); /* walk through the opened door */ { VectorSet(vec, 112, 144, 32); VecToPos(vec, to); lengthStored = Grid_MoveLength(path, to, crouchingState, true); CU_ASSERT_EQUAL(lengthStored, TU_MOVE_STRAIGHT); } /* walk around the opened door */ { VectorSet(vec, 144, 208, 32); VecToPos(vec, to); lengthStored = Grid_MoveLength(path, to, crouchingState, true); CU_ASSERT_EQUAL(lengthStored, 2 * TU_MOVE_STRAIGHT + TU_MOVE_DIAGONAL); } } SV_ShutdownGameProgs(); }
static void testMoveEntities (void) { routing_t *routing; pos3_t pos; vec3_t vec; pathing_t *path = Mem_AllocType(pathing_t); pos_t *forbiddenList[MAX_FORBIDDENLIST]; int forbiddenListLength = 0; const byte crouchingState = 0; const int distance = MAX_ROUTE; SV_Map(qtrue, mapName, NULL); /* starting point */ VectorSet(vec, 240, -144, 32); VecToPos(vec, pos); routing = &sv->mapData.map[ACTOR_SIZE_NORMAL - 1]; G_CompleteRecalcRouting(); { edict_t *ent = NULL; while ((ent = G_EdictsGetNextInUse(ent))) { /* Dead 2x2 unit will stop walking, too. */ if (ent->type == ET_SOLID) { int j; for (j = 0; j < ent->forbiddenListSize; j++) { forbiddenList[forbiddenListLength++] = ent->forbiddenListPos[j]; forbiddenList[forbiddenListLength++] = (byte*) &ent->fieldSize; } } } } { int lengthStored; pos3_t to; Grid_MoveCalc(routing, ACTOR_SIZE_NORMAL, path, pos, crouchingState, distance, forbiddenList, forbiddenListLength); Grid_MoveStore(path); /* walk onto the func_breakable */ { VectorSet(vec, 112, -144, 32); VecToPos(vec, to); lengthStored = Grid_MoveLength(path, to, crouchingState, qtrue); CU_ASSERT_EQUAL(lengthStored, 4 * TU_MOVE_STRAIGHT); } /* walk over the func_breakable */ { VectorSet(vec, 80, -144, 32); VecToPos(vec, to); lengthStored = Grid_MoveLength(path, to, crouchingState, qtrue); CU_ASSERT_EQUAL(lengthStored, 5 * TU_MOVE_STRAIGHT); } /* walk over the func_breakable */ { VectorSet(vec, 16, -144, 32); VecToPos(vec, to); lengthStored = Grid_MoveLength(path, to, crouchingState, qtrue); CU_ASSERT_EQUAL(lengthStored, 7 * TU_MOVE_STRAIGHT); } } /* starting point */ VectorSet(vec, 144, 144, 32); VecToPos(vec, pos); { int lengthStored; pos3_t to; Grid_MoveCalc(routing, ACTOR_SIZE_NORMAL, path, pos, crouchingState, distance, forbiddenList, forbiddenListLength); Grid_MoveStore(path); /* walk through the opened door */ { VectorSet(vec, 112, 144, 32); VecToPos(vec, to); lengthStored = Grid_MoveLength(path, to, crouchingState, qtrue); CU_ASSERT_EQUAL(lengthStored, TU_MOVE_STRAIGHT); } /* walk around the opened door */ { VectorSet(vec, 144, 208, 32); VecToPos(vec, to); lengthStored = Grid_MoveLength(path, to, crouchingState, qtrue); CU_ASSERT_EQUAL(lengthStored, 2 * TU_MOVE_STRAIGHT + TU_MOVE_DIAGONAL); } } SV_ShutdownGameProgs(); }