Moved the common directory into the libs directory

This commit is contained in:
Kayne Ruse
2013-06-16 13:59:11 +10:00
parent a0fa874a29
commit 419c9d8765
13 changed files with 79 additions and 10 deletions
+3 -1
View File
@@ -1,7 +1,9 @@
#config
LIBDIR=..
LOCALLIBS=
LIB=
INCLUDES=
CXXFLAGS+=-std=c++11 -DDEBUG $(addprefix -I,$(INCLUDES))
LIB=
#source
SRC=$(wildcard *.cpp)
+3 -1
View File
@@ -1,7 +1,9 @@
#config
LIBDIR=..
LOCALLIBS=
LIB=
INCLUDES=
CFLAGS+=$(addprefix -I,$(INCLUDES))
LIB=
#source
SRC=$(wildcard *.c)
+8
View File
@@ -0,0 +1,8 @@
#ifndef DEFINES_HPP_
#define DEFINES_HPP
#include <chrono>
typedef std::chrono::high_resolution_clock Clock;
#endif
+39
View File
@@ -0,0 +1,39 @@
#config
LIBDIR=..
LOCALLIBS=$(LIBDIR)/out/libCodebase.a
LIB=
INCLUDES=$(LIBDIR)/Codebase
CXXFLAGS+=-std=c++11 -DDEBUG $(addprefix -I,$(INCLUDES))
#source
SRC=$(wildcard *.cpp)
#objects
OBJDIR=obj
OBJ=$(addprefix $(OBJDIR)/,$(SRC:.cpp=.o))
#output
OUTDIR=../out
OUT=$(addprefix $(OUTDIR)/,libCommon.a)
#targets
all: $(OBJ) $(OUT)
ar -crs $(OUT) $(OBJ)
$(OBJ): | $(OBJDIR)
$(OUT): | $(OUTDIR)
$(OBJDIR):
mkdir $(OBJDIR)
$(OUTDIR):
mkdir $(OUTDIR)
$(OBJDIR)/%.o: %.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<
clean:
$(RM) *.o *.a *.exe
rebuild: clean all
+15
View File
@@ -0,0 +1,15 @@
#include "network_queue.hpp"
#include "SDL/SDL_thread.h"
#include <deque>
static std::deque<Packet> queue;
int networkQueue(void*) {
//
}
Packet getPacket() {
//
}
+9
View File
@@ -0,0 +1,9 @@
#ifndef NETWORKQUEUE_HPP_
#define NETWORKQUEUE_HPP_
#include "packet_type.hpp"
int networkQueue(void*);
Packet getPacket();
#endif
+102
View File
@@ -0,0 +1,102 @@
#ifndef PACKETTYPE_HPP_
#define PACKETTYPE_HPP_
#include "vector2.hpp"
#define PACKET_STRING_SIZE 100
#pragma pack(push, 0)
enum class PacketType {
NONE = 0,
PING = 1,
PONG = 2,
BROADCAST_REQUEST = 3,
BROADCAST_RESPONSE = 4,
JOIN_REQUEST = 5,
JOIN_RESPONSE = 6,
DISCONNECT = 7,
SYNCHRONIZE = 8,
PLAYER_NEW = 9,
PLAYER_DELETE = 10,
PLAYER_MOVE = 11,
};
struct Ping {
PacketType type;
};
struct Pong {
PacketType type;
};
struct BroadcastRequest {
PacketType type;
};
struct BroadcastResponse {
PacketType type;
char name[PACKET_STRING_SIZE];
//TODO: version
};
struct JoinRequest {
PacketType type;
//TODO: player data
};
struct JoinResponse {
PacketType type;
int playerIndex;
//resource list
};
struct Disconnect {
PacketType type;
};
struct Synchronize {
PacketType type;
};
struct PlayerNew {
PacketType type;
int playerIndex;
//TODO Playerdata
};
struct PlayerDelete {
PacketType type;
int playerIndex;
};
struct PlayerMove {
PacketType type;
int playerIndex;
Vector2 position;
Vector2 motion;
};
union Packet {
Packet() {};
PacketType type = PacketType::NONE;
Ping ping;
Pong pong;
BroadcastRequest broadcastRequest;
BroadcastResponse broadcastResponse;
JoinRequest joinRequest;
JoinResponse joinResponse;
Disconnect disconnect;
PlayerNew playerNew;
PlayerDelete playerDelete;
PlayerMove playerMove;
};
#pragma pack(pop)
#endif
+21
View File
@@ -0,0 +1,21 @@
#ifndef SERVICELOCATOR_HPP_
#define SERVICELOCATOR_HPP_
template<typename T>
class ServiceLocator {
public:
static T* Set(T* t) {
delete service;
return service = t;
}
static T* Get() {
return service;
}
private:
static T* service;
};
template<typename T>
T* ServiceLocator<T>::service = nullptr;
#endif
+1
View File
@@ -3,6 +3,7 @@ OUTDIR=out
all: $(OUTDIR)
$(MAKE) -C SDL_net
$(MAKE) -C codebase
$(MAKE) -C common
$(OUTDIR):
mkdir $(OUTDIR)