# network_server.h

    00001 /* $Id: network_server.h 9050 2007-03-07 11:47:46Z rubidium $ */
    00002
    00003 #ifndef NETWORK_SERVER_H
    00004 #define NETWORK_SERVER_H
    00005
    00006 #ifdef ENABLE_NETWORK
    00007
    00008 DEF_SERVER_SEND_COMMAND(PACKET_SERVER_MAP);
    00009 DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_ERROR_QUIT)(NetworkTCPSocketHandler *cs, uint16 client_index, NetworkErrorCode errorno);
    00010 DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_ERROR)(NetworkTCPSocketHandler *cs, NetworkErrorCode error);
    00011 DEF_SERVER_SEND_COMMAND(PACKET_SERVER_SHUTDOWN);
    00012 DEF_SERVER_SEND_COMMAND(PACKET_SERVER_NEWGAME);
    00013 DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_RCON)(NetworkTCPSocketHandler *cs, uint16 color, const char *command);
    00014
    00015 bool NetworkFindName(char new_name[NETWORK_CLIENT_NAME_LENGTH]);
    00016 void NetworkServer_HandleChat(NetworkAction action, DestType type, int dest, const char *msg, uint16 from_index);
    00017
    00018 bool NetworkServer_ReadPackets(NetworkTCPSocketHandler *cs);
    00019 void NetworkServer_Tick(bool send_frame);
    00020 void NetworkServerMonthlyLoop();
    00021 void NetworkServerYearlyLoop();
    00022
    00023 static inline const char* GetPlayerIP(const NetworkClientInfo* ci)
    00024 {
    00025   struct in_addr addr;
    00026
    00027   addr.s_addr = ci->client_ip;
    00028   return inet_ntoa(addr);
    00029 }
    00030
    00031 #else /* ENABLE_NETWORK */
    00032 /* Network function stubs when networking is disabled */
    00033
    00034 static inline void NetworkServerMonthlyLoop() {}
    00035 static inline void NetworkServerYearlyLoop() {}
    00036
    00037 #endif /* ENABLE_NETWORK */
    00038
    00039 #endif /* NETWORK_SERVER_H */