Add Windows cross-platform support alongside Linux

Replace POSIX-specific socket and process APIs with portable
abstractions so the project builds on both Windows and Linux.

- Add include/network/net_platform.hpp: Winsock2/POSIX socket
  abstraction (socket types, non-blocking, error handling,
  WSAStartup lifecycle)
- Add include/platform/process.hpp: CreateProcess/fork+exec
  abstraction for spawning ffplay subprocesses
- Update network module (tcp_socket, world_socket) to use
  portable socket helpers instead of raw POSIX calls
- Update audio module (music_manager, footstep_manager,
  activity_sound_manager) to use portable process helpers
  instead of fork/exec/kill/waitpid
- Replace hardcoded /tmp/ paths with std::filesystem::temp_directory_path()
- Link ws2_32 and SDL2main on Windows in CMakeLists.txt
This commit is contained in:
Kelsi 2026-02-03 22:24:17 -08:00
parent dd126c6e4b
commit 6bf3fa4ed4
14 changed files with 416 additions and 186 deletions

View file

@ -1,6 +1,7 @@
#pragma once
#include "audio/footstep_manager.hpp"
#include "platform/process.hpp"
#include <array>
#include <chrono>
#include <cstdint>
@ -51,10 +52,10 @@ private:
bool swimmingActive = false;
bool swimMoving = false;
pid_t swimLoopPid = -1;
pid_t oneShotPid = -1;
std::string loopTempPath = "/tmp/wowee_swim_loop.wav";
std::string oneShotTempPath = "/tmp/wowee_activity.wav";
ProcessHandle swimLoopPid = INVALID_PROCESS;
ProcessHandle oneShotPid = INVALID_PROCESS;
std::string loopTempPath = platform::getTempFilePath("wowee_swim_loop.wav");
std::string oneShotTempPath = platform::getTempFilePath("wowee_activity.wav");
std::mt19937 rng;
std::chrono::steady_clock::time_point lastJumpAt{};

View file

@ -1,10 +1,10 @@
#pragma once
#include "platform/process.hpp"
#include <cstdint>
#include <random>
#include <string>
#include <vector>
#include <sys/types.h>
#include <chrono>
namespace wowee {
@ -56,8 +56,8 @@ private:
SurfaceSamples surfaces[7];
size_t sampleCount = 0;
std::string tempFilePath = "/tmp/wowee_footstep.wav";
pid_t playerPid = -1;
std::string tempFilePath = platform::getTempFilePath("wowee_footstep.wav");
ProcessHandle playerPid = INVALID_PROCESS;
std::chrono::steady_clock::time_point lastPlayTime = std::chrono::steady_clock::time_point{};
std::mt19937 rng;

View file

@ -1,5 +1,6 @@
#pragma once
#include "platform/process.hpp"
#include <string>
#include <vector>
@ -31,7 +32,7 @@ private:
pipeline::AssetManager* assetManager = nullptr;
std::string currentTrack;
std::string tempFilePath;
pid_t playerPid = -1;
ProcessHandle playerPid = INVALID_PROCESS;
bool playing = false;
// Crossfade state