1 /** @file d_netsv.h  Common code related to net games (server-side).
2  *
3  * @authors Copyright © 2003-2017 Jaakko Keränen <jaakko.keranen@iki.fi>
4  * @authors Copyright © 2005-2013 Daniel Swanson <danij@dengine.net>
5  *
6  * @par License
7  * GPL: http://www.gnu.org/licenses/gpl.html
8  *
9  * <small>This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by the
11  * Free Software Foundation; either version 2 of the License, or (at your
12  * option) any later version. This program is distributed in the hope that it
13  * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15  * Public License for more details. You should have received a copy of the GNU
16  * General Public License along with this program; if not, write to the Free
17  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18  * 02110-1301 USA</small>
19  */
20 
21 #ifndef LIBCOMMON_NETSV_H
22 #define LIBCOMMON_NETSV_H
23 
24 #include <de/reader.h>
25 #include "common.h"
26 
27 DENG_EXTERN_C char cyclingMaps, mapCycleNoExit;
28 DENG_EXTERN_C int netSvAllowCheats;
29 DENG_EXTERN_C int netSvAllowSendMsg;
30 DENG_EXTERN_C char *mapCycle;
31 DENG_EXTERN_C char gameConfigString[];
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 /**
38  * Server calls this when new players enter the game.
39  */
40 void NetSv_NewPlayerEnters(int plrNum);
41 
42 /**
43  * Resets a player's frag count and other players' frag counts toward the player.
44  *
45  * @param plrNum  Player to reset.
46  */
47 void NetSv_ResetPlayerFrags(int plrNum);
48 
49 void NetSv_SendGameState(int flags, int to);
50 
51 void NetSv_SendTotalCounts(int to);
52 
53 /**
54  * Sends the initial player position to a client. This is the position defined
55  * by the map's start spots. It is sent immediately after the server determines
56  * where a player is to spawn.
57  */
58 void NetSv_SendPlayerSpawnPosition(int plrNum, float x, float y, float z, int angle);
59 
60 void NetSv_SendMessage(int plrNum, char const *msg);
61 
62 void NetSv_SendYellowMessage(int plrNum, char const *msg);
63 
64 void NetSv_SendPlayerState(int srcPlrNum, int destPlrNum, int flags, dd_bool reliable);
65 
66 /**
67  * More player state information. Had to be separate because of backwards
68  * compatibility.
69  */
70 void NetSv_SendPlayerState2(int srcPlrNum, int destPlrNum, int flags, dd_bool reliable);
71 
72 void NetSv_TellCycleRulesToPlayerAfterTics(int destPlr, int tics);
73 
74 /**
75  * Informs a player of an impulse momentum that needs to be applied to the player's mobj.
76  */
77 void NetSv_PlayerMobjImpulse(mobj_t *mobj, float mx, float my, float mz);
78 
79 /**
80  * Forcibly dismisses HUDs (automap, inventory) of a particular player.
81  *
82  * @param player  Player number.
83  * @param fast    Quick dismiss.
84  */
85 void NetSv_DismissHUDs(int player, dd_bool fast);
86 
87 /**
88  * @param origin
89  * @param soundId
90  * @param toPlr    @c 0= broadcast.
91  */
92 void NetSv_Sound(mobj_t *origin, int soundId, int toPlr);
93 
94 void NetSv_SoundAtVolume(mobj_t *origin, int soundId, int volume, int toPlr);
95 
96 void NetSv_Intermission(int flags, int state, int time);
97 
98 void NetSv_ChangePlayerInfo(int from, Reader1 *reader);
99 
100 void NetSv_SendPlayerInfo(int whose, int toWhom);
101 
102 /**
103  * Sharp ticker, i.e., called at 35 Hz.
104  */
105 void NetSv_Ticker(void);
106 
107 void NetSv_SaveGame(uint gameId);
108 
109 void NetSv_LoadGame(uint gameId);
110 
111 void NetSv_LoadReply(int plnum, int console);
112 
113 /**
114  * Sends the frags of player 'whose' to all other players.
115  */
116 void NetSv_FragsForAll(player_t *player);
117 
118 /**
119  * Send one of the kill messages, depending on the weapon of the killer.
120  */
121 void NetSv_KillMessage(player_t *killer, player_t *fragged, dd_bool stomping);
122 
123 /**
124  * Update the game config string with keywords that describe the game.
125  * The string is sent out in netgames (also to the master).
126  * Keywords: dm, coop, jump, nomonst, respawn, skillN
127  */
128 void NetSv_UpdateGameConfigDescription(void);
129 
130 /**
131  * Inform all clients about a change in the 'pausedness' of a game.
132  */
133 void NetSv_Paused(int pauseState);
134 
135 /**
136  * Process the requested cheat command, if possible.
137  */
138 void NetSv_DoCheat(int player, Reader1 *reader);
139 
140 void NetSv_ExecuteCheat(int player, char const *command);
141 
142 /**
143  * Process the requested player action, if possible.
144  */
145 void NetSv_DoAction(int player, Reader1 *reader);
146 
147 void NetSv_DoDamage(int player, Reader1 *reader);
148 
149 void NetSv_DoFloorHit(int player, Reader1 *msg);
150 
151 /**
152  * The default jump power is 9.
153  */
154 void NetSv_SendJumpPower(int target, float power);
155 
156 void NetSv_MaybeChangeWeapon(int plrNum, int weapon, int ammo, int force);
157 
158 void NetSv_SendLocalMobjState(mobj_t *mobj, char const *stateName);
159 
160 D_CMD(MapCycle);
161 
162 #ifdef __cplusplus
163 } // extern "C"
164 #endif
165 
166 #endif // LIBCOMMON_NETSV_H
167