Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build on Windows
name: Build

on:
push:
Expand Down Expand Up @@ -31,4 +31,21 @@ jobs:
run: xmake build proxy

- name: Build launcher
run: xmake build launcher
run: xmake build launcher

build-linux:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Install Xmake
uses: xmake-io/github-action-setup-xmake@v1
with:
xmake-version: latest

- name: Build server
run: xmake build -y server

- name: Run server
run: timeout 5 xmake run server || [ $? -eq 124 ]
6 changes: 6 additions & 0 deletions client/src/CPacketFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,9 @@ extern inline CPacketFactory& GetPacketFactory()
static CPacketFactory factory;
return factory;
}

template <typename PacketT>
PacketRegistrar<PacketT>::PacketRegistrar()
{
GetPacketFactory().RegisterPacket(new PacketT);
}
5 changes: 3 additions & 2 deletions server/src/CNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ void CNetwork::HandlePlayerConnected(ENetPeer* pENetPeer, Packets::System::Playe

playerid_t newPlayerId = CNetworkPlayerManager::AllocatePlayerId();
CNetworkPlayer* pNewNetworkPlayer = new CNetworkPlayer(pENetPeer, newPlayerId);
strcpy_s(pNewNetworkPlayer->m_Name, playerConnected.payload.name);
snprintf(pNewNetworkPlayer->m_Name, sizeof(pNewNetworkPlayer->m_Name), "%s", playerConnected.payload.name);
CNetworkPlayerManager::Add(pNewNetworkPlayer);

logger::info("playerid %s name %s version %s", to_string(newPlayerId).c_str(), playerConnected.payload.name, buffer);
Expand All @@ -192,7 +192,8 @@ void CNetwork::HandlePlayerConnected(ENetPeer* pENetPeer, Packets::System::Playe
continue;
}
oldPlayerConnected.payload.SetPlayerId(pNetworkPlayer->m_playerId);
strcpy_s(oldPlayerConnected.payload.name, pNetworkPlayer->m_Name);
snprintf(
oldPlayerConnected.payload.name, sizeof(oldPlayerConnected.payload.name), "%s", pNetworkPlayer->m_Name);
GetPacketFactory().Send(oldPlayerConnected, pNewNetworkPlayer);
}

Expand Down
6 changes: 6 additions & 0 deletions server/src/CPacketFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,10 @@ extern inline CPacketFactory& GetPacketFactory()
{
static CPacketFactory factory;
return factory;
}

template <typename PacketT>
PacketRegistrar<PacketT>::PacketRegistrar()
{
GetPacketFactory().RegisterPacket(new PacketT);
}
12 changes: 10 additions & 2 deletions server/src/CServerTime.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
#include "stdafx.h"
#include <chrono>

server_time_t g_serverTime = 0;

uint32_t CServerTime::m_serverStartedAt = 0;

// wraps like GetTickCount, unsigned subtraction keeps the elapsed time correct
static uint32_t GetTickCountMs()
{
using namespace std::chrono;
return static_cast<uint32_t>(duration_cast<milliseconds>(steady_clock::now().time_since_epoch()).count());
}

void CServerTime::Init()
{
m_serverStartedAt = GetTickCount();
m_serverStartedAt = GetTickCountMs();
}

void CServerTime::Update()
{
g_serverTime = GetTickCount() - m_serverStartedAt;
g_serverTime = GetTickCountMs() - m_serverStartedAt;
}

PACKET_HANDLER(ePacketType::SERVER_TIME_REQUEST, Packets::System::ServerTimeRequest* pServerTimeRequest,
Expand Down
3 changes: 1 addition & 2 deletions server/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,5 @@ int main(int argc, char* argv[])
CConfigManager::Init();
CServerTime::Init();

CNetwork::Init(CConfigManager::GetConfigPort());
return 0;
return CNetwork::Init(CConfigManager::GetConfigPort()) ? 0 : 1;
}
4 changes: 4 additions & 0 deletions server/src/sdk/CEntryExit.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Server stand-in for plugin-sdk CEntryExit.h: only what the shared packets need.
#pragma once

#include "SEntryExitFlags.h"
22 changes: 22 additions & 0 deletions server/src/sdk/CExplosion.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Server stand-in for plugin-sdk CExplosion.h: only what the shared packets need.
// Keep in sync with third_party/plugin-sdk/plugin_sa/game_sa/CExplosion.h
#pragma once

#include "CVector.h"

enum eExplosionType
{
EXPLOSION_GRENADE,
EXPLOSION_MOLOTOV,
EXPLOSION_ROCKET,
EXPLOSION_WEAK_ROCKET,
EXPLOSION_CAR,
EXPLOSION_QUICK_CAR,
EXPLOSION_BOAT,
EXPLOSION_AIRCRAFT,
EXPLOSION_MINE,
EXPLOSION_OBJECT,
EXPLOSION_TANK_FIRE,
EXPLOSION_SMALL,
EXPLOSION_RC_VEHICLE
};
27 changes: 27 additions & 0 deletions server/src/sdk/CGame.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Server stand-in for plugin-sdk CGame.h: only what the shared packets need.
// Keep in sync with third_party/plugin-sdk/plugin_sa/game_sa/CGame.h
#pragma once

enum eVisibleArea
{
AREA_MAIN_MAP = 0,
AREA_HOTEL,
AREA_MANSION,
AREA_BANK,
AREA_MALL,
AREA_STRIP_CLUB,
AREA_LAWYERS,
AREA_COFFEE_SHOP,
AREA_CONCERT_HALL,
AREA_STUDIO,
AREA_RIFLE_RANGE,
AREA_BIKER_BAR,
AREA_POLICE_STATION,
AREA_EVERYWHERE,
AREA_DIRT,
AREA_BLOOD,
AREA_OVALRING,
AREA_MALIBU_CLUB,
AREA_PRINT_WORKS,
MAX_VISIBLE_AREAS
};
39 changes: 39 additions & 0 deletions server/src/sdk/CPad.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Server stand-in for plugin-sdk CPad.h: only what the shared packets need.
// Keep in sync with third_party/plugin-sdk/plugin_sa/game_sa/CPad.h
#pragma once

class CControllerState
{
public:
signed short LeftStickX; // move/steer left (-128?)/right (+128)
signed short LeftStickY; // move back(+128)/forwards(-128?)
signed short RightStickX; // numpad 6(+128)/numpad 4(-128?)
signed short RightStickY;

signed short LeftShoulder1;
signed short LeftShoulder2;
signed short RightShoulder1; // target / hand brake
signed short RightShoulder2;

signed short DPadUp; // radio change up Next radio station / Call gang forward/Recruit gang member
signed short DPadDown; // radio change down Previous radio station / Gang stay back/Release gang (hold)
signed short DPadLeft; // Skip trip/Action / Negative talk reply
signed short DPadRight; // Next user MP3 track / Positive talk reply

signed short Start; // Pause
signed short Select; // Camera modes

signed short ButtonSquare; // jump / reverse Break/Reverse / Jump/Climb
signed short ButtonTriangle; // get in/out Exit vehicle / Enter veihcle
signed short ButtonCross; // sprint / accelerate Accelerate / Sprint/Swim
signed short ButtonCircle; // fire Fire weapon

signed short ShockButtonL;
signed short ShockButtonR; // look behind

signed short m_bChatIndicated;
signed short m_bPedWalk;
signed short m_bVehicleMouseLook;
signed short m_bRadioTrackSkip;
};
static_assert(sizeof(CControllerState) == 0x30, "Invalid structure size of CControllerState");
17 changes: 17 additions & 0 deletions server/src/sdk/CPed.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Server stand-in for plugin-sdk CPed.h: only what the shared packets need.
// Keep in sync with third_party/plugin-sdk/plugin_sa/game_sa/CPed.h
#pragma once

#include "ePedType.h"

enum PLUGIN_API eMoveState
{
PEDMOVE_NONE = 0,
PEDMOVE_STILL,
PEDMOVE_TURN_L,
PEDMOVE_TURN_R,
PEDMOVE_WALK,
PEDMOVE_JOG,
PEDMOVE_RUN,
PEDMOVE_SPRINT
};
116 changes: 116 additions & 0 deletions server/src/sdk/CRadar.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
// Server stand-in for plugin-sdk CRadar.h: only what the shared packets need.
// Keep in sync with third_party/plugin-sdk/plugin_sa/game_sa/CRadar.h
#pragma once

#define MAX_RADAR_TRACES (175)

enum eBlipType
{
BLIP_NONE,
BLIP_CAR,
BLIP_CHAR,
BLIP_OBJECT,
BLIP_COORD,
BLIP_CONTACTPOINT,
BLIP_SPOTLIGHT,
BLIP_PICKUP,
BLIP_AIRSTRIP
};

enum eCoordBlipAppearance
{
COORD_BLIP_APPEARANCE_NORMAL,
COORD_BLIP_APPEARANCE_FRIEND,
COORD_BLIP_APPEARANCE_ENEMY
};

enum eBlipDisplay
{
BLIP_DISPLAY_NEITHER, // 0
BLIP_DISPLAY_MARKER_ONLY, // 1
BLIP_DISPLAY_BLIP_ONLY, // 2
BLIP_DISPLAY_BOTH // 3
};

enum eBlipColour
{
BLIP_COLOUR_RED, // 0
BLIP_COLOUR_GREEN, // 1
BLIP_COLOUR_BLUE, // 2
BLIP_COLOUR_WHITE, // 3
BLIP_COLOUR_YELLOW, // 4
BLIP_COLOUR_REDCOPY, // 5 - What? It was BLIP_COLOUR_PURPLE.
BLIP_COLOUR_BLUECOPY, // 6 - Why? It was BLIP_COLOUR_CYAN.
BLIP_COLOUR_THREAT, // 7 - If BLIP_FLAG_FRIENDLY is not set (by default) it is BLIP_COLOUR_RED, else
// BLIP_COLOUR_BLUE.
BLIP_COLOUR_DESTINATION // 8 - Default color.
};

enum eRadarSprite {
RADAR_SPRITE_NONE, // 0
RADAR_SPRITE_WHITE, // 1
RADAR_SPRITE_CENTRE, // 2
RADAR_SPRITE_MAP_HERE, // 3
RADAR_SPRITE_NORTH, // 4
RADAR_SPRITE_AIRYARD, // 5
RADAR_SPRITE_AMMUGUN, // 6
RADAR_SPRITE_BARBERS, // 7
RADAR_SPRITE_BIGSMOKE, // 8
RADAR_SPRITE_BOATYARD, // 9
RADAR_SPRITE_BURGERSHOT, // 10
RADAR_SPRITE_BULLDOZER, // 11
RADAR_SPRITE_CATALINAPINK, // 12
RADAR_SPRITE_CESARVIAPANDO, // 13 - What? R* mistype?
RADAR_SPRITE_CHICKEN, // 14
RADAR_SPRITE_CJ, // 15
RADAR_SPRITE_CRASH1, // 16
RADAR_SPRITE_DINER, // 17 - Yet another one?
RADAR_SPRITE_EMMETGUN, // 18
RADAR_SPRITE_ENEMYATTACK, // 19
RADAR_SPRITE_FIRE, // 20
RADAR_SPRITE_GIRLFRIEND, // 21
RADAR_SPRITE_HOSTPITAL, // 22 - Again?
RADAR_SPRITE_LOGOSYNDICATE, // 23
RADAR_SPRITE_MADDOG, // 24
RADAR_SPRITE_MAFIACASINO, // 25
RADAR_SPRITE_MCSTRAP, // 26
RADAR_SPRITE_MODGARAGE, // 27
RADAR_SPRITE_OGLOC, // 28
RADAR_SPRITE_PIZZA, // 29
RADAR_SPRITE_POLICE, // 30
RADAR_SPRITE_PROPERTYG, // 31
RADAR_SPRITE_PROPERTYR, // 32
RADAR_SPRITE_RACE, // 33
RADAR_SPRITE_RYDER, // 34
RADAR_SPRITE_SAVEGAME, // 35
RADAR_SPRITE_SCHOOL, // 36
RADAR_SPRITE_QMARK, // 37
RADAR_SPRITE_SWEET, // 38
RADAR_SPRITE_TATTOO, // 39
RADAR_SPRITE_THETRUTH, // 40
RADAR_SPRITE_WAYPOINT, // 41
RADAR_SPRITE_TORENORANCH, // 42
RADAR_SPRITE_TRIADS, // 43
RADAR_SPRITE_TRIADSCASINO, // 44
RADAR_SPRITE_TSHIRT, // 45
RADAR_SPRITE_WOOZIE, // 46
RADAR_SPRITE_ZERO, // 47
RADAR_SPRITE_DATEDISCO, // 48
RADAR_SPRITE_DATEDRINK, // 49
RADAR_SPRITE_DATEFOOD, // 50
RADAR_SPRITE_TRUCK, // 51
RADAR_SPRITE_CASH, // 52
RADAR_SPRITE_FLAG, // 53
RADAR_SPRITE_GYM, // 54
RADAR_SPRITE_IMPOUND, // 55
RADAR_SPRITE_LIGHT, // 56
RADAR_SPRITE_RUNWAY, // 57
RADAR_SPRITE_GANGB, // 58
RADAR_SPRITE_GANGP, // 59
RADAR_SPRITE_GANGY, // 60
RADAR_SPRITE_GANGN, // 61
RADAR_SPRITE_GANGG, // 62
RADAR_SPRITE_SPRAY,/*, // 63
RADAR_SPRITE_TORENO*/ // 64
RADAR_SPRITE_COUNT,
};
41 changes: 41 additions & 0 deletions server/src/sdk/CVector.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Server stand-in for plugin-sdk CVector.h: only what the shared packets need.
// Keep in sync with third_party/plugin-sdk/plugin_sa/game_sa/CVector.h
#pragma once

#include "PluginBase.h"

class CVector
{
public:
float x, y, z;

CVector() { x = y = z = 0.0f; }
CVector(float X, float Y, float Z)
{
x = X;
y = Y;
z = Z;
}
};

inline CVector operator-(const CVector& vecOne, const CVector& vecTwo)
{
return CVector(vecOne.x - vecTwo.x, vecOne.y - vecTwo.y, vecOne.z - vecTwo.z);
}

inline CVector operator+(const CVector& vecOne, const CVector& vecTwo)
{
return CVector(vecOne.x + vecTwo.x, vecOne.y + vecTwo.y, vecOne.z + vecTwo.z);
}

inline CVector operator*(const CVector& vec, float multiplier)
{
return CVector(vec.x * multiplier, vec.y * multiplier, vec.z * multiplier);
}

inline CVector operator*(float multiplier, const CVector& vec)
{
return CVector(vec.x * multiplier, vec.y * multiplier, vec.z * multiplier);
}

VALIDATE_SIZE(CVector, 0xC);
Loading