Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

Play_server.cpp

Go to the documentation of this file.
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         // Server main loop
00042         //-----------------------------------------------------------------##
00043         for (i=0; i<SPLAYER_MAX_PLAYERS; i++) {
00044                 if (g_players[i].state == PLAYER_STATE_OFFLINE)
00045                         continue;
00046 
00047                 //-----------------------------------------------------------------#
00048                 // Player died (score dealed in "dealDamage")
00049                 //-----------------------------------------------------------------#
00050                 //if (g_players[i].life <= 0) {
00051                 //      g_players[i].life = 100.0f;
00052 
00053                         // Notify all (player explode and new state)
00054                 //      gne->setPlayerAction(i, PLAY_ACTION_PLAYER_EXPLODE);
00055 
00056                         //if (ownerID == playerID)
00057                         //      console.addEx(Vec3(1.0f, 1.0f, 0.1f), "'%s' got tired of life", g_players[ownerID].name);
00058                         //else
00059                         //      console.addEx(Vec3(1.0f, 0.1f, 0.1f), "'%s' killed by '%s'", g_players[playerID].name, g_players[ownerID].name);
00060                 //}
00061 
00062                 //-----------------------------------------------------------------#
00063                 // Set spawn point (and spawn)
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); // right order (when received)?
00077                         }
00078                 }
00079 
00080                 //-----------------------------------------------------------------#
00081                 // Don't need to spawn any more
00082                 //-----------------------------------------------------------------#
00083                 else if (g_players[i].state == PLAYER_STATE_SPAWNING && g_time >= g_players[i].spawnTime) {
00084                         //g_players[i].spawnTime = 0.0f;
00085                         //g_players[i].state = PLAYER_STATE_USER;
00086 
00087                         //gne->setPlayerState(i, g_players[i].state);
00088                         gne->setPlayerAction(i, PLAY_ACTION_PLAYER_SPAWNED);
00089 
00090                 }
00091         }
00092 }

Generated on Sun Jun 5 15:47:05 2005 for Defacto by  doxygen 1.4.3