source: Daodan/MSVC/Flatline.h@ 748

Last change on this file since 748 was 589, checked in by gumby, 13 years ago

stuff

File size: 6.0 KB
RevLine 
[567]1#pragma once
2#ifndef FLATLINE_H
3#define FLATLINE_H
4
5#include <stdlib.h>
6#include <stdio.h>
7#include <time.h>
8//#define DDrStartupMessage printf
9
10#include <string.h>
11#include "bool.h"
12////#include <stdint.h>
13
14#define thread __thread
15
[589]16#include "Flatline_Public.h"
17
[567]18#ifdef WIN32
19#include <winsock2.h>
20#include "Flatline_Win32.h"
21#else
22#include <sys/ioctl.h>
23#include <sys/types.h>
24#include <sys/socket.h>
25#include <unistd.h>
26#include <stropts.h>
27#include <arpa/inet.h>
28#include <netinet/in.h>
29
30#define NetPlatform_Initalize() /* */
31#define NetPlatform_Shutdown() /* */
32#define closesocket close
33#define ioctlsocket ioctl
34#endif
35
36#include "Daodan.h"
37#include "BFW_Utility.h"
38#include "Daodan_Console.h"
39#include "Oni_Character.h"
[584]40#include "Flatline_Packet.h"
[567]41
42
[587]43//#define breakpoint asm("int3")
[567]44
45
[587]46#include "Flatline_Net.h"
[567]47
48DWORD WINAPI StartServer(void* lol);
49DWORD WINAPI StartClient(void* lol);
50
51
52//initial connection
53typedef struct {
54 char country[2];
55 char name[256];
56} connect_send; //signature="CONNECT\0"
57
58//reply to connection.
59//goodtogo is if it is going to let you in
60//message is optional, only used for denial message
61typedef struct {
62 bool goodtogo;
63 int player_slot;
64 char message[256];
65} connect_reply;
66
67//um, status of the server? :/
[578]68//probably obsolete. revive again once i do something crazy
69//like make a master server
[567]70typedef struct {
71 char name[256];
72 uint32_t numplayers; //signature="STATUS\0\0"
73} server_status;
74
75typedef struct {
76 uint16_t Playernumber;
77 CharacterObject Character;
78} new_player;
79
[568]80//extern int update_rate;
[567]81
82typedef struct {
83 float MouseDeltaX;
84 float MouseDeltaY;
85 uint32_t Actions1;
86 uint32_t Actions2;
[586]87 float DesiredFacing;
88 //unsigned int Time;
[567]89} input_struct;
90
91//TODO:
92//Varient
93//Figure out + fix overlays
94//AC->HeadFacing
95//AC->HeadPitch
96typedef struct {
[573]97 uint16_t throwing;
98 uint16_t throwFrame;
99 char throwName[32];
100} td;
[584]101/*
[573]102typedef struct {
[567]103 uint16_t PlayerNum;
[582]104 //Vector3 Position;
105
106 //float Facing;
107 //float DesiredFacing;
108
109 float UD;
110 float LR;
111
[567]112 uint32_t Health;
113 uint32_t MaxHealth;
[581]114 //input_struct Inputs;
[568]115 int rare_sync_index;
[573]116 char Animation[32];
[567]117 uint16_t Frame;
[573]118 td throw_data;
119 int Kills;
120 int Damage;
121 int Deaths;
[580]122 uint16_t Ping;
[582]123
[567]124} player_data;
125
[568]126//todo, move health in...
[584]127/*typedef struct {
[568]128 short unsigned int PlayerNum;
129 unsigned int index;
130 Inventory Inventory;
131 char Class[32];
132} rare_sync_data;
[584]133*/
[573]134typedef struct {
135 unsigned int event_index;
136 int intArray[];
137} flatline_event;
[584]138/*
[581]139typedef struct {
[582]140 int16_t PlayerNum;
[581]141 float MouseDeltaX;
142 float MouseDeltaY;
143 uint32_t Actions1;
144 uint32_t Actions2;
[582]145 float Facing;
146 float DesiredFacing;
147 Vector3 Position;
[581]148} player_input;
[584]149*/
[567]150//used for storing data about each player
151typedef struct {
[583]152 //int FLATLINE;
[587]153 short signature;
154 short id;
155 int size;
156 //int packet_index;
[573]157 union
[567]158 {
159 char data[1080];
160 connect_reply connect_reply;
161 connect_send connect_send;
162 input_struct input_struct;
163 new_player new_player;
164 server_status server_status;
[584]165 //player_data player_data;
166 //rare_sync_data rare_sync_data;
[568]167 uint16_t sync_request;
[573]168 flatline_event flatline_event;
[580]169 uint32_t ping;
[584]170 //player_input all_input[33];
[586]171 uint32_t integer; //generic integer ;)
[567]172 };
173} flatline_packet;
[568]174#define FLATLINE_HEADER (sizeof(flatline_packet)-sizeof(char)*1080)
[567]175//#define FLATLINE_PACKET_SIZE sizeof(flatline_packet)
176
177
178bool FLrServer_PacketCallback(char* data, int datalen, int from);
179bool FLrServer_Run();
180bool FLrClient_Run(flatline_packet* packet);
181extern int sock;
182
183enum {
[579]184 NULL_PACKET, //Don't use. ;)
[567]185 CONNECT_SEND,
186 CONNECT_REPLY,
187 STATUS,
188 MESSAGE,
189 CHANGE_NAME,
190 ECHO,
191 NEW_PLAYER,
192 PLAYER_INPUT,
[584]193 //PLAYER_DATA,
194 //RARE_SYNC_DATA,
195 //RARE_SYNC_DATA_REQUEST,
[573]196 FLATLINE_EVENT,
[580]197 PK_PING,
198 PK_PONG,
[584]199 //PK_ALL_INPUT,
200 PK_PLAYER_DATA,
[586]201 PK_MISSING_PLAYER,
[567]202};
203
[573]204enum FlatlineEvent {
205 EV_RESPAWN,
[583]206 EV_KILLED,
[573]207 EV_DISCONNECT,
208 EV_DOOR_OPEN,
[574]209 EV_CONSOLE_USE,
[573]210 EV_MAX,
211};
[567]212
[573]213
[582]214typedef struct {
215 //Server Only
216 bool PleaseUpdateAllPlayers;
217 //Client stuff (can be used by server "client")
[573]218
[582]219 //Move from random scattered bools to these, please.
220 bool ClientConnected;
221 unsigned int ClientSlot;
222 bool ServerStatus;
223} multiplayer_status;
224
[573]225enum {
226 STATE_ALIVE,
227 STATE_DEAD,
228};
229enum {
230 PF_HOST,
231 PF_BOT,
232 PF_SCRIPTEDAI,
233};
[567]234typedef struct {
235 int ip;
[568]236 char name[32];
[567]237 char country[2];
238 Character* Chr;
239 uint16_t spawnnumber;
240 uint16_t list_slot;
[584]241
242 PlayerInput InputFromClient;
[586]243 float FacingFromClient;
[584]244
245 ////////////////////////////
246 //Sync stuff
247 ////////////////////////////
248 uint16_t UpdateFlags;
249
250 PlayerInput Input;
251 PlayerHealth Health;
252 PlayerFacing Facings;
253 PlayerScore Score;
254 void* Animation;
[586]255 char AnimationString[32];
[584]256 uint16_t Frame;
257 PlayerThrowData ThrowData;
258 void* Class;
[586]259 char ClassString[32];
[584]260 PlayerInventory Inventory;
[582]261 Vector3 Position;
[584]262 ////////////////////////////
263 bool HasAppliedThrow;
[582]264
[568]265 unsigned int LastInputTime;
[584]266
267
[573]268 uint16_t state;
269 int flags;
[579]270 int DeathTime;
[580]271 uint32_t Ping;
272 bool DataApplied;
[583]273 bool NeedToSetFP;
[582]274 uint32_t ShapeshiftCooldown;
[567]275} player_info;
276
277player_info * FLr_FindEmptySlot();
278uint16_t FLr_FindEmptyListSlot();
279void * ONICALL FLrInput_Update_Keys(void);
280
281void NetCatchError();
[580]282#define MAX_PLAYERS 32
[567]283#define CONNECTION_TIMEOUT 15
284#define MAX_CONNECTIONS 32
285#define NetTCPSocket_Send NetUDPSocket_Send
286#define NetTCPServer_Send NetUDPServer_Send
287extern int client_sock;
288//these two could probably be combined
289extern sockaddr_in client_address;
290extern sockaddr_in address;
291extern player_info Players[];
292extern player_info * PlayerList[];
[582]293extern multiplayer_status MultiplayerStatus;
[567]294int UDPServer_SendToAll(void* packet, int size);
[580]295
296
[573]297void FLrRun_Scores();
[579]298void FLrPlayerDisconnect( int Player );
299void FLrPlayerRespawn( int Player );
[573]300int FLrEvent_GetNumArgs( int eventIndex );
[582]301bool FlatlineInitialize();
[584]302
303bool DoWeUpdateThis( uint16_t BitSet, uint16_t Flag );
304
[580]305extern unsigned int lastPingTime;
[567]306#endif
Note: See TracBrowser for help on using the repository browser.