Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Iswenzz committed Dec 18, 2022
2 parents d305026 + ba83598 commit 8798780
Show file tree
Hide file tree
Showing 34 changed files with 504 additions and 397 deletions.
18 changes: 0 additions & 18 deletions .conan/patches/CMakeLists.txt.patch

This file was deleted.

34 changes: 25 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.16.0)
project(CGSC VERSION 1.1.0 LANGUAGES C)
project(CGSC VERSION 1.2.0 LANGUAGES C)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
Expand Down Expand Up @@ -33,16 +33,32 @@ if(ENABLE_TESTING)
endif()

# Build
add_library(CGSC)
add_subdirectory(api)
add_subdirectory(asm)
add_subdirectory(extensions)
if(PLUGIN)
add_library(CGSC INTERFACE CGSC/cgsc.h CGSC/plugin.h)
target_include_directories(CGSC INTERFACE . cod4x/plugins)
else()
add_library(CGSC STATIC cgsc.h cod4x.h)

add_subdirectory(asm)
add_subdirectory(extensions)
add_subdirectory(sys)
add_subdirectory(utils)
add_subdirectory(versions)

target_link_libraries(CGSC PUBLIC ${CONAN_LIBS})
target_compile_definitions(CGSC PUBLIC COD4X18UPDATE)
target_include_directories(CGSC PUBLIC . .. ../version ../../plugins)
set_target_properties(CGSC PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ../../../lib)

target_compile_definitions(CGSC PUBLIC COD4X18UPDATE)
target_include_directories(CGSC PUBLIC . .. ../version ../../plugins)
target_sources(CGSC PRIVATE cgsc.h)
set(STATIC_DEPENDENCIES
${CONAN_LIB_DIRS_LIBUV}/libuv_a.a)

foreach(dependency ${STATIC_DEPENDENCIES})
add_custom_command(TARGET CGSC POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${dependency} ../../../lib)
endforeach()
endif()

set_target_properties(CGSC PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ../../../lib)
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SOURCES})

# Pack
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![CodeFactor](https://img.shields.io/codefactor/grade/github/Iswenzz/CGSC?label=codefactor&logo=codefactor)](https://www.codefactor.io/repository/github/iswenzz/CGSC)
[![License](https://img.shields.io/github/license/Iswenzz/CGSC?color=blue&logo=gitbook&logoColor=white)](https://github.com/Iswenzz/CGSC/blob/master/LICENSE)

This Call of Duty 4X source extension adds new utilities for use in the creation of new plugins. Such things include new functions to get data types that the original source doesn't offer and adds the ability to call functions defined in GSC from the C files. To use this extension you must add the CGSC files included in the release section to the `/src/CGSC` folder, and then compile the CoD4X server source. More detailed instructions can be found towards the bottom of this document.
This Call of Duty 4X source extension adds new utilities to extend the server and the creation of new plugins. Such things include new functions to get data types that the original source doesn't offer, the ability to call functions defined in GSC from the C files and async workers for expensive operations on the server. To use this extension you must add the CGSC files included in the release section to the `/src/CGSC` folder, and then compile the CoD4X server source. More detailed instructions can be found towards the bottom of this document.

``Note: Depending on the version of Call of Duty 4X that you're running, some features of CGSC may not be available.``

Expand All @@ -15,7 +15,7 @@ This Call of Duty 4X source extension adds new utilities for use in the creation

## Instructions
In order to use this extension, just download the archived file down below, and extract it to the cod4x server's ``src/CGSC`` directory, then copy the makefile snippet below and paste it before the default rule.
Then simply build the cod4x source with ``make``.
Then simply build the library with the build instructions and recompile the cod4x source with ``make``.

### **[Download](https://github.com/Iswenzz/CGSC/releases)**

Expand All @@ -24,9 +24,9 @@ Then simply build the cod4x source with ``make``.
##################################
# CGSC
CGSC_DIR=$(SRC_DIR)/CGSC
WIN_LLIBS:=$(WIN_LLIBS) CGSC
LINUX_LLIBS:=$(LINUX_LLIBS) CGSC
BSD_LLIBS:=$(BSD_LLIBS) CGSC
WIN_LLIBS:=$(WIN_LLIBS) CGSC uv_a iphlpapi psapi userenv ws2_32
LINUX_LLIBS:=$(LINUX_LLIBS) CGSC uv_a dl pthread rt
BSD_LLIBS:=$(BSD_LLIBS) CGSC uv_a dl pthread rt

WIN_LFLAGS:=$(WIN_LFLAGS) -mconsole

Expand Down
7 changes: 0 additions & 7 deletions api/CMakeLists.txt

This file was deleted.

20 changes: 0 additions & 20 deletions api/cod4x.h

This file was deleted.

36 changes: 0 additions & 36 deletions api/sys/compatibility.h

This file was deleted.

46 changes: 0 additions & 46 deletions api/utils/utils.h

This file was deleted.

3 changes: 0 additions & 3 deletions api/versions/CMakeLists.txt

This file was deleted.

13 changes: 11 additions & 2 deletions asm/cgsc_export.asm
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@
p%2 dd %2
%endmacro

; CGSC
; Rename
ralias Plugin_Scr_GetFunction, Scr_GetFunc

; Plugin export
pexport Scr_ReturnResult
pexport Scr_AddFunc
pexport Scr_AddVariable
Expand All @@ -45,4 +46,12 @@ pexport Scr_GetTop
pexport Sys_GetCommonVersion
pexport Scr_SelectParamOrDefault
pexport Scr_SelectParam
pexport Scr_SetParamGeneric
pexport Scr_SetParamGeneric
pexport AsyncShutdown
pexport AsyncCall
pexport AsyncNull
pexport AsyncFree
pexport CGSC_Version
pexport CGSC_Unsupported
pexport CGSC_UnsupportedMessage
pexport CGSC_SupportIndexedString
2 changes: 1 addition & 1 deletion asm/cgsc_function.asm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

SECTION .text

; Scr_ExecThreadResult(int, unsigned int)
; Scr_ExecThreadResult(int threadId, unsigned int argsCount)
Scr_ExecThreadResult:
push ebp
mov ebp, esp
Expand Down
33 changes: 21 additions & 12 deletions cgsc.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
#pragma once

#ifdef _WIN32
#define NOGDI
#include <winsock2.h>
#include <mswsock.h>
#include <windows.h>
#endif

#ifdef COD4X18UPDATE
#include "api/cod4x.h"
#include "cod4x.h"
#else
#include "api/plugin.h"
#include "plugin.h"
#endif

#ifdef PLUGIN_HANDLER_VERSION_MAJOR
Expand All @@ -13,21 +20,18 @@
#define CGSC_EQ(version) CGSCH == version

#if PLUGIN_HANDLER_VERSION_MAJOR >= 4
#include "api/versions/cgsc4.h"
#include "versions/cgsc4.h"
#elif PLUGIN_HANDLER_VERSION_MAJOR >= 3
#include "api/versions/cgsc3.h"
#include "versions/cgsc3.h"
#endif
#endif

#ifdef SYS_COMMONVERSION
#define COD4X(version) SYS_COMMONVERSION
#endif

/**
* @brief
* Adds the definition for plugin exports.
*/
#define Plugin(type, definition) \
/// @brief Adds the definition for cod4x server and plugin export.
#define EXPORT(type, definition) \
type definition; \
type Plugin_##definition

Expand Down Expand Up @@ -98,14 +102,19 @@ struct scrStringDebugGlob_t
int ignoreLeaks;
};

struct __attribute__((aligned (64))) scrVarGlob_t
{
VariableValueInternal* variableList;
};

typedef struct
{
uint32_t length;
VariableValue *items;
} VariableValueArray;

#include "api/sys/compatibility.h"
#include "api/utils/utils.h"

#include "sys/compatibility.h"
#include "sys/async.h"
#include "extensions/functions.h"
#include "extensions/variables.h"
#include "utils/utils.h"
20 changes: 20 additions & 0 deletions cod4x.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once
#define COD4X

#ifndef PLUGIN_HANDLER_VERSION_MAJOR
#include <plugin_declarations.h>
#endif

#define CHECK_UNSUPPORTED(condition) \
if (CGSC_UnsupportedMessage(condition, "CGSC: This feature is unsupported in this version.")) \
{ \
Scr_AddUndefined(); \
return; \
}

#include <version.h>
#include <scr_vm.h>
#include <scr_vm_functions.h>
#include <q_shared.h>

#undef ASSERT
Loading

0 comments on commit 8798780

Please sign in to comment.