network_server.h
author peter1138
Mon, 23 Oct 2006 18:45:43 +0000
changeset 4930 708801d486c6
parent 4906 935e6280c093
permissions -rw-r--r--
(svn r6910) - Codechange: Supply width of area when drawing purchase info instead of using hardcoded values. (mart3p)
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 1026
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 1026
diff changeset
     2
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff changeset
     3
#ifndef NETWORK_SERVER_H
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff changeset
     4
#define NETWORK_SERVER_H
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff changeset
     5
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff changeset
     6
#ifdef ENABLE_NETWORK
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff changeset
     7
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff changeset
     8
DEF_SERVER_SEND_COMMAND(PACKET_SERVER_MAP);
716
8af847728d5b (svn r1168) -Cleanup: [Network] Cleaned the network code a bit. Added 'const'
truelight
parents: 690
diff changeset
     9
DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_ERROR_QUIT)(NetworkClientState *cs, uint16 client_index, NetworkErrorCode errorno);
8af847728d5b (svn r1168) -Cleanup: [Network] Cleaned the network code a bit. Added 'const'
truelight
parents: 690
diff changeset
    10
DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_ERROR)(NetworkClientState *cs, NetworkErrorCode error);
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff changeset
    11
DEF_SERVER_SEND_COMMAND(PACKET_SERVER_SHUTDOWN);
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff changeset
    12
DEF_SERVER_SEND_COMMAND(PACKET_SERVER_NEWGAME);
1026
02cc18821508 (svn r1527) -Add: RCon (Remote Connection). A server can set:
truelight
parents: 839
diff changeset
    13
DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_RCON)(NetworkClientState *cs, uint16 color, const char *command);
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff changeset
    14
3623
9b612a4bbd39 (svn r4521) - Fix: be consistent about the size of the player-name in MP. This hopefully fixes a crash on lesser OS's (eg Win98). Use ttd_strlcpy() to just copy over strings and properly terminate them because different implementations of snprintf() behave differently. Courtesy of TrueLight
Darkvater
parents: 2548
diff changeset
    15
bool NetworkFindName(char new_name[NETWORK_CLIENT_NAME_LENGTH]);
4906
935e6280c093 (svn r6876) -Codechange: Change the naming of _PLAYER in DESTTYPE_PLAYER/NETWORK_ACTION_CHAT_PLAYER
Darkvater
parents: 4830
diff changeset
    16
void NetworkServer_HandleChat(NetworkAction action, DestType type, int dest, const char *msg, uint16 from_index);
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff changeset
    17
716
8af847728d5b (svn r1168) -Cleanup: [Network] Cleaned the network code a bit. Added 'const'
truelight
parents: 690
diff changeset
    18
bool NetworkServer_ReadPackets(NetworkClientState *cs);
2235
7630c38913fd (svn r2755) Fix: Fix a desync issue with autoreplace
ludde
parents: 2186
diff changeset
    19
void NetworkServer_Tick(bool send_frame);
716
8af847728d5b (svn r1168) -Cleanup: [Network] Cleaned the network code a bit. Added 'const'
truelight
parents: 690
diff changeset
    20
void NetworkServerMonthlyLoop(void);
785
bba7b3b35dec (svn r1252) -Add: [Network] With 'set restart_game_date' you can set the date for in
truelight
parents: 716
diff changeset
    21
void NetworkServerYearlyLoop(void);
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff changeset
    22
2548
49c8a096033f (svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents: 2538
diff changeset
    23
static inline const char* GetPlayerIP(const NetworkClientInfo* ci)
49c8a096033f (svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents: 2538
diff changeset
    24
{
4490
a8c299022281 (svn r6275) Get rid of an ugly cast
tron
parents: 3623
diff changeset
    25
	struct in_addr addr;
a8c299022281 (svn r6275) Get rid of an ugly cast
tron
parents: 3623
diff changeset
    26
a8c299022281 (svn r6275) Get rid of an ugly cast
tron
parents: 3623
diff changeset
    27
	addr.s_addr = ci->client_ip;
a8c299022281 (svn r6275) Get rid of an ugly cast
tron
parents: 3623
diff changeset
    28
	return inet_ntoa(addr);
2548
49c8a096033f (svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents: 2538
diff changeset
    29
}
2538
2e9c118c5e93 (svn r3067) - Feature: allow unbanning players based on banlist-id (as well as IP).
Darkvater
parents: 2436
diff changeset
    30
4830
668bcb0a30b2 (svn r6754) -Codechange: Remove some #idef ENABLE_NETWORK specific defines. With networking
Darkvater
parents: 4490
diff changeset
    31
#else /* ENABLE_NETWORK */
668bcb0a30b2 (svn r6754) -Codechange: Remove some #idef ENABLE_NETWORK specific defines. With networking
Darkvater
parents: 4490
diff changeset
    32
/* Network function stubs when networking is disabled */
668bcb0a30b2 (svn r6754) -Codechange: Remove some #idef ENABLE_NETWORK specific defines. With networking
Darkvater
parents: 4490
diff changeset
    33
668bcb0a30b2 (svn r6754) -Codechange: Remove some #idef ENABLE_NETWORK specific defines. With networking
Darkvater
parents: 4490
diff changeset
    34
static inline void NetworkServerMonthlyLoop(void) {}
668bcb0a30b2 (svn r6754) -Codechange: Remove some #idef ENABLE_NETWORK specific defines. With networking
Darkvater
parents: 4490
diff changeset
    35
static inline void NetworkServerYearlyLoop(void) {}
668bcb0a30b2 (svn r6754) -Codechange: Remove some #idef ENABLE_NETWORK specific defines. With networking
Darkvater
parents: 4490
diff changeset
    36
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff changeset
    37
#endif /* ENABLE_NETWORK */
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff changeset
    38
2436
7d5df545bd5d (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2235
diff changeset
    39
#endif /* NETWORK_SERVER_H */