Spacewar/source/Spacewar-Server.h

59 lines
1.8 KiB
C
Raw Normal View History

2023-10-08 21:22:21 +00:00
// =========================================
// | Spacewar-Server.h |
// | Copyright (C) 2023, Barra Ó Catháin |
// | See end of file for copyright notice. |
// =========================================
#ifndef SPACEWAR_SERVER
#define SPACEWAR_SERVER
2023-10-13 13:44:24 +00:00
#include <sys/types.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <netinet/in.h>
2023-10-08 21:22:21 +00:00
#include "Spacewar-Physics.h"
typedef struct SpacewarState SpacewarState;
2023-10-08 21:22:21 +00:00
typedef struct SpacewarConnection
{
2023-10-13 13:44:24 +00:00
bool active;
2023-10-08 21:22:21 +00:00
int clientSocket;
2023-10-13 13:44:24 +00:00
uint8_t missedPongs;
uint32_t playerSecret;
2023-10-08 21:22:21 +00:00
struct sockaddr_in clientAddress;
} SpacewarConnection;
2023-10-13 13:44:24 +00:00
typedef struct SpacewarServerConfiguration
{
uint16_t port;
} SpacewarServerConfiguration;
typedef struct SpacewarServerSharedState
{
SpacewarState * state;
SpacewarConnection * connections;
} SpacewarServerSharedState;
2023-10-08 21:22:21 +00:00
// Creates a spacewar server, intended to be ran by the standalone server or forked by the game client:
2023-10-13 13:44:24 +00:00
void * runSpacewarServer(void * configuration);
2023-10-08 21:22:21 +00:00
#endif
// =======================================================
// | End of Spacewar-Server.h, copyright notice follows. |
// =======================================================
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.