diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1855e6e --- /dev/null +++ b/.gitignore @@ -0,0 +1,21 @@ +# Build output +AAServer/AAServer +AAServer/*.o + +# macOS +.DS_Store + +# VS Code (keep .vscode/ tracked, but ignore local overrides) +.vscode/ + +# MSVC / Windows build artifacts +AAServer/Debug/ +AAServer/Release/ +AAServer/ipch/ +AAServer/*.sdf +AAServer/*.suo +AAServer/*.opensdf + +# Spec / scratch +spec/ +.claude \ No newline at end of file diff --git a/AAServer/.gitignore b/AAServer/.gitignore deleted file mode 100644 index 3645f1d..0000000 --- a/AAServer/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/Debug -/ipch -/Release -/AAServer.sdf -/AAServer.suo -/AAServer.opensdf diff --git a/AAServer/AAServer.cpp b/AAServer/AAServer.cpp index dd4ccbf..dae4a4f 100644 --- a/AAServer/AAServer.cpp +++ b/AAServer/AAServer.cpp @@ -3,7 +3,11 @@ #include "stdafx.h" #include "config.h" +#ifdef _WIN32 #include +#else +#include +#endif #include "ipxserver.h" #include #include @@ -333,7 +337,11 @@ bool IPX_StartServer(Bit16u portnum) // 1 second has gone by UpdateConnections(); } +#ifdef _WIN32 Sleep(1); +#else + usleep(1000); +#endif } return true; @@ -343,7 +351,7 @@ bool IPX_StartServer(Bit16u portnum) return false; } -int _tmain(int argc, _TCHAR* argv[]) +int main(int argc, char* argv[]) { printf("Amulets & Armor IPX Server v1.00\n"); printf("--------------------------------\n"); @@ -358,7 +366,13 @@ int _tmain(int argc, _TCHAR* argv[]) exit(2); } - IPX_StartServer(213); + Bit16u port = 213; + if (argc > 1) { + port = (Bit16u)atoi(argv[1]); + } + printf("Starting on port %d\n", port); + fflush(stdout); + IPX_StartServer(port); return 0; } diff --git a/AAServer/Makefile b/AAServer/Makefile new file mode 100644 index 0000000..14a9053 --- /dev/null +++ b/AAServer/Makefile @@ -0,0 +1,22 @@ +CXX = clang++ +CC = clang +INCLUDES = -I. -I/usr/local/include/SDL2 +CFLAGS = $(INCLUDES) -DNDEBUG +CXXFLAGS = $(CFLAGS) -std=c++14 +LDFLAGS = -L/usr/local/lib -lSDL2 -lSDL2_net +TARGET = AAServer +OBJS = AAServer.o PACKETPR.o + +$(TARGET): $(OBJS) + $(CXX) $(OBJS) $(LDFLAGS) -o $(TARGET) + +AAServer.o: AAServer.cpp + $(CXX) $(CXXFLAGS) -c AAServer.cpp -o AAServer.o + +PACKETPR.o: PACKETPR.C + $(CC) $(CFLAGS) -c PACKETPR.C -o PACKETPR.o + +clean: + rm -f $(OBJS) $(TARGET) + +.PHONY: clean diff --git a/AAServer/config.h b/AAServer/config.h index df859c2..72c4d08 100644 --- a/AAServer/config.h +++ b/AAServer/config.h @@ -1,15 +1,25 @@ #ifndef _AASERVER_CONFIG_H_ #define _AASERVER_CONFIG_H_ -#define GCC_ATTRIBUTE(x) /* attribute not supported */ #define GCC_UNLIKELY(x) (x) #define GCC_LIKELY(x) (x) +#ifdef _MSC_VER +#define GCC_ATTRIBUTE(x) /* attribute not supported */ #define INLINE __forceinline #define DB_FASTCALL __fastcall +typedef unsigned __int64 Bit64u; +typedef signed __int64 Bit64s; +#else +#define GCC_ATTRIBUTE(x) __attribute__((x)) +#define INLINE inline +#define DB_FASTCALL +typedef unsigned long long Bit64u; +typedef signed long long Bit64s; +#endif -#if defined(_MSC_VER) && (_MSC_VER >= 1400) -#pragma warning(disable : 4996) +#if defined(_MSC_VER) && (_MSC_VER >= 1400) +#pragma warning(disable : 4996) #endif @@ -20,8 +30,6 @@ typedef unsigned short Bit16u; typedef signed short Bit16s; typedef unsigned long Bit32u; typedef signed long Bit32s; -typedef unsigned __int64 Bit64u; -typedef signed __int64 Bit64s; typedef unsigned int Bitu; typedef signed int Bits; diff --git a/AAServer/stdafx.h b/AAServer/stdafx.h index 47a0d02..2d56009 100644 --- a/AAServer/stdafx.h +++ b/AAServer/stdafx.h @@ -5,10 +5,12 @@ #pragma once +#ifdef _WIN32 #include "targetver.h" +#include +#endif #include -#include