Skip to content
This repository has been archived by the owner on Oct 21, 2023. It is now read-only.

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
psychonic committed Oct 21, 2023
0 parents commit 5c91bdc
Show file tree
Hide file tree
Showing 32 changed files with 7,600 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.tlog
*.db
*.exp
*.sdf
162 changes: 162 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
###########################################
### EDIT THESE PATHS FOR YOUR OWN SETUP ###
###########################################

HL2SDK_DOTA = ../hl2sdk-dota
MMSOURCE = ../metamod-source

#####################################
### EDIT BELOW FOR OTHER PROJECTS ###
#####################################

PROJECT = d2lobby

OBJECTS_MAIN = \
constants.cpp \
d2lobby.cpp \
eventlog.cpp \
forcedheroes.cpp \
gcmgr.cpp \
httpmgr.cpp \
lobbymgr.cpp \
logger.cpp \
norunes.cpp \
pb2json.cpp \
pluginsystem.cpp \
scripttools.cpp \
steamnet.cpp \
util.cpp

OBJECTS_PROTO = \
generated_proto/base_gcmessages.pb.cc \
generated_proto/dota_client_enums.pb.cc \
generated_proto/dota_commonmessages.pb.cc \
generated_proto/dota_gcmessages_client_match_management.pb.cc \
generated_proto/dota_gcmessages_common.pb.cc \
generated_proto/dota_gcmessages_common_match_management.pb.cc \
generated_proto/dota_gcmessages_server.pb.cc \
generated_proto/dota_shared_enums.pb.cc \
generated_proto/dota_usermessages.pb.cc \
generated_proto/econ_gcmessages.pb.cc \
generated_proto/econ_shared_enums.pb.cc \
generated_proto/gcsdk_gcmessages.pb.cc \
generated_proto/network_connection.pb.cc \
generated_proto/networkbasetypes.pb.cc \
generated_proto/steammessages.pb.cc

##############################################
### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###
##############################################

C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing
C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3
C_GCC4_FLAGS = -fvisibility=hidden -fPIC
CPP_GCC4_FLAGS = -fvisibility-inlines-hidden
CPP = clang

HL2PUB = $(HL2SDK_DOTA)/public

INCLUDE += -I$(HL2SDK_DOTA)/common/protobuf-2.6.1/src -I$(HL2SDK_DOTA)/public/game/server \
-I../jansson-2.5/src -I../steamworks/public -I../subhook
METAMOD = $(MMSOURCE)/core

LIB_EXT = so
HL2LIB = $(HL2SDK_DOTA)/lib/linux

LIB_PREFIX = lib
LIB_SUFFIX = .$(LIB_EXT)

INCLUDE += -I. -I..

LINK += -Wl,--exclude-libs,ALL -lm -lgcc_eh -lstdc++ $(HL2LIB)/tier1_i486.a libsteam_api.so $(LIB_PREFIX)vstdlib$(LIB_SUFFIX) $(LIB_PREFIX)tier0$(LIB_SUFFIX) $(HL2LIB)/interfaces_i486.a ../jansson-2.5/src/.libs/libjansson.a ../protobuf-2.6.1/src/.libs/libprotobuf.a ../subhook/libsubhook.a

INCLUDE += -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 -I$(METAMOD) \
-I$(METAMOD)/sourcehook

LINK += -m64 -lm -ldl -shared

CFLAGS += -D_LINUX -DLINUX -DPOSIX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \
-D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -DCOMPILER_GCC -Wall \
-Wno-overloaded-virtual -Wno-switch -Wno-unused -msse -DHAVE_STDINT_H -m64 -DPLATFORM_64BITS \
-DVERSION_SAFE_STEAM_API_INTERFACES -DSUBHOOK_IMPLEMENTATION
CPPFLAGS += -Wno-non-virtual-dtor -fno-exceptions -std=c++11

################################################
### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ###
################################################

BINARY = $(PROJECT).$(LIB_EXT)

ifeq "$(DEBUG)" "true"
BIN_DIR = Debug
CFLAGS += $(C_DEBUG_FLAGS)
else
BIN_DIR = Release
CFLAGS += $(C_OPT_FLAGS)
endif

LIB_EXT = so

IS_CLANG := $(shell $(CPP) --version | head -1 | grep clang > /dev/null && echo "1" || echo "0")

ifeq "$(IS_CLANG)" "1"
CPP_MAJOR := $(shell $(CPP) --version | grep clang | sed "s/.*version \([0-9]\)*\.[0-9]*.*/\1/")
CPP_MINOR := $(shell $(CPP) --version | grep clang | sed "s/.*version [0-9]*\.\([0-9]\)*.*/\1/")
else
CPP_MAJOR := $(shell $(CPP) -dumpversion >&1 | cut -b1)
CPP_MINOR := $(shell $(CPP) -dumpversion >&1 | cut -b3)
endif

# If not clang
ifeq "$(IS_CLANG)" "0"
CFLAGS += -mfpmath=sse
endif

# Clang || GCC >= 4
ifeq "$(shell expr $(IS_CLANG) \| $(CPP_MAJOR) \>= 4)" "1"
CFLAGS += $(C_GCC4_FLAGS)
CPPFLAGS += $(CPP_GCC4_FLAGS)
endif

# Clang >= 3 || GCC >= 4.7
ifeq "$(shell expr $(IS_CLANG) \& $(CPP_MAJOR) \>= 3 \| $(CPP_MAJOR) \>= 4 \& $(CPP_MINOR) \>= 7)" "1"
CFLAGS += -Wno-delete-non-virtual-dtor
endif

# OS is Linux and not using clang
#ifeq "$(shell expr $(IS_CLANG) \= 0)" "1"
# LINK += -static-libgcc
#endif

OBJ_MAIN_BIN := $(OBJECTS_MAIN:%.cpp=$(BIN_DIR)/%.o)
OBJ_PROTO_BIN := $(OBJECTS_PROTO:generated_proto/%.cc=$(BIN_DIR)/generated_proto/%.o)

MAKEFILE_NAME := $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))

$(BIN_DIR)/%.o: %.cpp
$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<

$(BIN_DIR)/generated_proto/%.o: generated_proto/%.cc
$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<

all:
mkdir -p $(BIN_DIR)
mkdir -p $(BIN_DIR)/generated_proto
ln -sf $(HL2LIB)/$(LIB_PREFIX)vstdlib$(LIB_SUFFIX); \
ln -sf $(HL2LIB)/$(LIB_PREFIX)tier0$(LIB_SUFFIX); \
ln -sf ../steamworks/redistributable_bin/linux64/libsteam_api.so; \
$(MAKE) -f $(MAKEFILE_NAME) extension

extension: $(OBJ_MAIN_BIN) $(OBJ_PROTO_BIN)
$(CPP) $(INCLUDE) $(OBJ_MAIN_BIN) $(OBJ_PROTO_BIN) $(LINK) -o $(BIN_DIR)/$(BINARY)

debug:
$(MAKE) -f $(MAKEFILE_NAME) all DEBUG=true

default: all

clean:
rm -rf $(BIN_DIR)/*.o
rm -rf $(BIN_DIR)/$(BINARY)
rm -rf $(BIN_DIR)/generated_proto/*.o

13 changes: 13 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# D2Lobby2 - A Dota 2 match plugin

This is D2Lobby2, a Metamod:Source server plugin for Dota 2 match management. It was previously closed source and has been unmaintained since 2016. Now that general interest in modding the Source 2 engine has increased, I've decided to open this up in case it is useful to someone. Note that it will not function in its current state due to changes in the engine and game.

No support is provided.

Dependencies:

* Metamod:Source
* AlliedModders "HL2SDK" (dota branch)
* Protobuf
* Jansson
* subhook
33 changes: 33 additions & 0 deletions constants.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* =============================================================================
* D2Lobby2
* Copyright (C) 2023 Nicholas Hastings
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 2.0 or later, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*
* As a special exception, you are also granted permission to link the code
* of this program (as well as its derivative works) to "Dota 2," the
* "Source Engine, and any Game MODs that run on software by the Valve Corporation.
* You must obey the GNU General Public License in all respects for all other
* code used. Additionally, this exception is granted to all derivative works.
*/

#include "constants.h"

const char *g_ColorGreen = "#99FF99";
const char *g_ColorDarkGreen = "#40FF40";
const char *g_ColorBlue = "#99CCFF";
const char *g_ColorRed = "#FF3F3F";
const char *g_ColorYellow = "#FFB200";
const char *g_ColorGrey = "#CCCCCC";
76 changes: 76 additions & 0 deletions constants.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/**
* =============================================================================
* D2Lobby2
* Copyright (C) 2023 Nicholas Hastings
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 2.0 or later, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*
* As a special exception, you are also granted permission to link the code
* of this program (as well as its derivative works) to "Dota 2," the
* "Source Engine, and any Game MODs that run on software by the Valve Corporation.
* You must obey the GNU General Public License in all respects for all other
* code used. Additionally, this exception is granted to all derivative works.
*/

#pragma once

#define MSG_TAG "[D2Lobby] "

const int kMaxTeamPlayers = 5;
const int kMaxGamePlayerIds = 10;
const int kSpectatorIdStart = kMaxGamePlayerIds;
const int kMaxTotalPlayerIds = 32;
const int kMaxBroadcastChannels = 6;
const int kMaxBroadcastChannelSlots = 4;
const int kMaxPlayerNameLength = 128;

// Classic Source colors
extern const char *g_ColorGreen;
extern const char *g_ColorDarkGreen;
extern const char *g_ColorBlue;
extern const char *g_ColorRed;
extern const char *g_ColorYellow;
extern const char *g_ColorGrey;

enum DotaTeam
{
kTeamUnassigned = 0,
kTeamSpectators = 1,
kTeamRadiant = 2,
kTeamDire = 3,
kTeamNeutrals = 4,
};

enum DotaRune : int
{
DoubleDamage,
Haste,
Illusion,
Invisibility,
Regeneration,
Bounty,
Arcane,
};

enum class DotaSeriesType
{
None,
BO3,
BO5,
};

#define HUD_PRINTNOTIFY 1
#define HUD_PRINTCONSOLE 2
#define HUD_PRINTTALK 3
#define HUD_PRINTCENTER 4
Loading

0 comments on commit 5c91bdc

Please sign in to comment.