00001
00010 #include "Play.h"
00011
00012 void Play::serverLoop() {
00013 unsigned int i;
00014
00015 if (!gne->isRunning() || !gne->isServer())
00016 return;
00017
00018 if (g_gameInfo.gameState == GAME_STATE_WAITING) {
00019 bool allReady = true;
00020 for (i=0; i<SPLAYER_MAX_PLAYERS; i++) {
00021 if (g_players[i].state == PLAYER_STATE_LOADING) {
00022 allReady = false;
00023 break;
00024 }
00025 }
00026
00027 if (allReady) {
00028 gne->setPlayerExtras(PLAY_NET_START_GAME, 0, 0);
00029 }
00030
00031 return;
00032 }
00033
00034 if (g_time >= m_timeEnd) {
00035 gne->setPlayerExtras(PLAY_NET_GAME_OVER, 0, 0);
00036 }
00037
00038 dealExtras();
00039
00040
00041
00042
00043 for (i=0; i<SPLAYER_MAX_PLAYERS; i++) {
00044 if (g_players[i].state == PLAYER_STATE_OFFLINE)
00045 continue;
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 else if (g_players[i].state == PLAYER_STATE_INVISIBLE && g_players[i].spawnTime > 0.0f) {
00066 if (g_players[i].spawnTime <= g_time) {
00067 Vec3 pos = m_objLevel->getSpawnpool();
00068 g_players[i].state = PLAYER_STATE_SPAWNING;
00069 g_players[i].pos = pos;
00070 g_players[i].spawnTime = g_time + 1500.0f;
00071
00072 g_players[i].rotation = PLAYER_ROTATION_NONE;
00073 g_players[i].moving = PLAYER_MOVING_NONE;
00074
00075 gne->setPlayerPos(i, PLAYER_ROTATION_NONE, PLAYER_MOVING_NONE, g_players[i].pos.x, g_players[i].pos.z, g_players[i].angle);
00076 gne->setPlayerAction(i, PLAY_ACTION_PLAYER_SPAWN);
00077 }
00078 }
00079
00080
00081
00082
00083 else if (g_players[i].state == PLAYER_STATE_SPAWNING && g_time >= g_players[i].spawnTime) {
00084
00085
00086
00087
00088 gne->setPlayerAction(i, PLAY_ACTION_PLAYER_SPAWNED);
00089
00090 }
00091 }
00092 }