Skip to content

Commit

Permalink
convert to metamod
Browse files Browse the repository at this point in the history
the angelscript version broke sometimes, preventing a level change from working or getting players stuck in intermission. Metamod can skip the entity hacks and hook the level change function directly, which should be much less error prone.
  • Loading branch information
wootguy committed Oct 28, 2022
1 parent 656b2ac commit 6335a62
Show file tree
Hide file tree
Showing 112 changed files with 12,941 additions and 146 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
48 changes: 48 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
cmake_minimum_required(VERSION 3.6)

set(SVEN_ROOT_PATH "C:/Games/Steam/steamapps/common/Sven Co-op/" CACHE FILEPATH "Where your Sven Co-op folder is")
set(DLL_INSTALL_PATH "svencoop/addons/metamod/dlls" CACHE FILEPATH "Where to install the DLL (relative to Sven Co-op folder)")

project(MapChangeMsg)

set(SOURCE_FILES
src/main.cpp
src/meta_init.h src/meta_init.cpp
)

include_directories(src)
include_directories(src/meta)
include_directories(include/metamod)
include_directories(include/hlsdk/common)
include_directories(include/hlsdk/dlls)
include_directories(include/hlsdk/engine)
include_directories(include/hlsdk/pm_shared)

add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES})

if(MSVC)
set_target_properties(${PROJECT_NAME} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${SVEN_ROOT_PATH}/${DLL_INSTALL_PATH}"
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${SVEN_ROOT_PATH}/${DLL_INSTALL_PATH}")

set_target_properties(${PROJECT_NAME} PROPERTIES
VS_STARTUP_PROJECT ${PROJECT_NAME}
VS_DEBUGGER_COMMAND "svencoop.exe"
VS_DEBUGGER_COMMAND_ARGUMENTS "+map stadium4 -nomsaa -nofbo -noborder -condebug"
VS_DEBUGGER_WORKING_DIRECTORY "${SVEN_ROOT_PATH}")

# can't overwrite dll while its loaded but it can be renamed, then you can run "meta reload <plugin>" to update it in-game
add_custom_command(TARGET ${PROJECT_NAME} PRE_BUILD
COMMAND ${CMAKE_CURRENT_LIST_DIR}/replace_dll.bat
)

else()
set(CMAKE_CXX_FLAGS "-Wall -std=c++11 -m32")
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
set(CMAKE_CXX_FLAGS_RELEASE "-Os -fno-exceptions -w -Wfatal-errors")
target_compile_definitions(${PROJECT_NAME} PUBLIC -Dlinux)

add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_CURRENT_LIST_DIR}/replace_dll.sh
)
endif()
146 changes: 0 additions & 146 deletions MapChangeMsg.as

This file was deleted.

3 changes: 3 additions & 0 deletions cmake.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mkdir build
cd build
cmake -A Win32 ..
64 changes: 64 additions & 0 deletions include/hlsdk/common/beamdef.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/***
*
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC.
*
****/
#if !defined ( BEAMDEFH )
#define BEAMDEFH
#ifdef _WIN32
#ifndef __MINGW32__
#pragma once
#endif /* not __MINGW32__ */
#endif

#define FBEAM_STARTENTITY 0x00000001
#define FBEAM_ENDENTITY 0x00000002
#define FBEAM_FADEIN 0x00000004
#define FBEAM_FADEOUT 0x00000008
#define FBEAM_SINENOISE 0x00000010
#define FBEAM_SOLID 0x00000020
#define FBEAM_SHADEIN 0x00000040
#define FBEAM_SHADEOUT 0x00000080
#define FBEAM_STARTVISIBLE 0x10000000 // Has this client actually seen this beam's start entity yet?
#define FBEAM_ENDVISIBLE 0x20000000 // Has this client actually seen this beam's end entity yet?
#define FBEAM_ISACTIVE 0x40000000
#define FBEAM_FOREVER 0x80000000

typedef struct beam_s BEAM;
struct beam_s
{
BEAM *next;
int type;
int flags;
vec3_t source;
vec3_t target;
vec3_t delta;
float t; // 0 .. 1 over lifetime of beam
float freq;
float die;
float width;
float amplitude;
float r, g, b;
float brightness;
float speed;
float frameRate;
float frame;
int segments;
int startEntity;
int endEntity;
int modelIndex;
int frameCount;
struct model_s *pFollowModel;
struct particle_s *particles;
};

#endif
117 changes: 117 additions & 0 deletions include/hlsdk/common/cl_entity.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/***
*
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC.
*
****/
// cl_entity.h
#if !defined( CL_ENTITYH )
#define CL_ENTITYH
#ifdef _WIN32
#ifndef __MINGW32__
#pragma once
#endif /* not __MINGW32__ */
#endif

typedef struct efrag_s
{
struct mleaf_s *leaf;
struct efrag_s *leafnext;
struct cl_entity_s *entity;
struct efrag_s *entnext;
} efrag_t;

typedef struct
{
byte mouthopen; // 0 = mouth closed, 255 = mouth agape
byte sndcount; // counter for running average
int sndavg; // running average
} mouth_t;

typedef struct
{
float prevanimtime;
float sequencetime;
byte prevseqblending[2];
vec3_t prevorigin;
vec3_t prevangles;

int prevsequence;
float prevframe;

byte prevcontroller[4];
byte prevblending[2];
} latchedvars_t;

typedef struct
{
// Time stamp for this movement
float animtime;

vec3_t origin;
vec3_t angles;
} position_history_t;

typedef struct cl_entity_s cl_entity_t;

#define HISTORY_MAX 64 // Must be power of 2
#define HISTORY_MASK ( HISTORY_MAX - 1 )


#if !defined( ENTITY_STATEH )
#include "entity_state.h"
#endif

#if !defined( PROGS_H )
#include "progs.h"
#endif

struct cl_entity_s
{
int index; // Index into cl_entities ( should match actual slot, but not necessarily )

qboolean player; // True if this entity is a "player"

entity_state_t baseline; // The original state from which to delta during an uncompressed message
entity_state_t prevstate; // The state information from the penultimate message received from the server
entity_state_t curstate; // The state information from the last message received from server

int current_position; // Last received history update index
position_history_t ph[ HISTORY_MAX ]; // History of position and angle updates for this player

mouth_t mouth; // For synchronizing mouth movements.

latchedvars_t latched; // Variables used by studio model rendering routines

// Information based on interplocation, extrapolation, prediction, or just copied from last msg received.
//
float lastmove;

// Actual render position and angles
vec3_t origin;
vec3_t angles;

// Attachment points
vec3_t attachment[4];

// Other entity local information
int trivial_accept;

struct model_s *model; // cl.model_precache[ curstate.modelindes ]; all visible entities have a model
struct efrag_s *efrag; // linked list of efrags
struct mnode_s *topnode; // for bmodels, first world node that splits bmodel, or NULL if not split

float syncbase; // for client-side animations -- used by obsolete alias animation system, remove?
int visframe; // last frame this entity was found in an active leaf
colorVec cvFloorColor;
};

#endif // !CL_ENTITYH
Loading

0 comments on commit 6335a62

Please sign in to comment.