Alibek Omarov
6 years ago
11 changed files with 521 additions and 2 deletions
@ -0,0 +1,80 @@
@@ -0,0 +1,80 @@
|
||||
#! /usr/bin/env python |
||||
# encoding: utf-8 |
||||
# mittorn, 2018 |
||||
|
||||
from waflib import Logs |
||||
import os |
||||
|
||||
top = '.' |
||||
|
||||
def options(opt): |
||||
# stub |
||||
return |
||||
|
||||
def configure(conf): |
||||
# check for dedicated server build |
||||
if conf.options.DEDICATED: |
||||
conf.check( lib='rt' ) |
||||
conf.env.append_unique('DEFINES', 'SINGLE_BINARY') |
||||
conf.env.append_unique('DEFINES', 'XASH_DEDICATED') |
||||
else: |
||||
# TODO: add way to specify SDL2 path, move to separate function |
||||
try: |
||||
conf.check_cfg( |
||||
path='sdl2-config', |
||||
args='--cflags --libs', |
||||
package='', |
||||
msg='Checking for SDL2', |
||||
uselib_store='SDL2') |
||||
except conf.errors.ConfigurationError: |
||||
conf.fatal('SDL2 not availiable! If you want to build dedicated server, specify --dedicated') |
||||
conf.env.append_unique('DEFINES', 'XASH_SDL') |
||||
|
||||
def get_subproject_name(ctx): |
||||
return os.path.basename(os.path.realpath(str(ctx.path))) |
||||
|
||||
def build(bld): |
||||
bld.load_envs() |
||||
bld.env = bld.all_envs[get_subproject_name(bld)] |
||||
|
||||
# basic build: dedicated only, no dependencies |
||||
if bld.env.DEST_OS != 'win32': |
||||
libs = [ 'DL', 'M', 'PTHREAD' ] |
||||
|
||||
source = bld.path.ant_glob([ |
||||
'common/*.c', |
||||
'common/imagelib/*.c', |
||||
'common/soundlib/*.c', |
||||
'common/soundlib/libmpg/*.c', |
||||
'server/*.c']) |
||||
|
||||
# add client files and sdl2 library |
||||
if not bld.env.DEDICATED: |
||||
libs.append( 'SDL2' ) |
||||
source += bld.path.ant_glob([ |
||||
'client/*.c', |
||||
'client/vgui/*.c', |
||||
'client/avi/*.c', |
||||
'platform/sdl/*.c']) |
||||
else: |
||||
if(bld.env.DEST_OS == 'linux'): |
||||
libs.append('RT') |
||||
|
||||
includes = ['common', 'server', 'client', 'client/vgui', '.', '../common', '../pm_shared' ] |
||||
|
||||
if(bld.env.SINGLE_BINARY): |
||||
bld( |
||||
source = source, |
||||
target = 'xash', |
||||
features = 'c cprogram', |
||||
includes = includes, |
||||
use = libs |
||||
) |
||||
else: |
||||
bld.shlib( |
||||
source = source, |
||||
target = 'xash', |
||||
features = 'c', |
||||
includes = includes, |
||||
use = libs |
||||
) |
@ -0,0 +1,185 @@
@@ -0,0 +1,185 @@
|
||||
/*
|
||||
game.cpp -- executable to run Xash Engine |
||||
Copyright (C) 2011 Uncle Mike |
||||
|
||||
This program is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU General Public License as published by |
||||
the Free Software Foundation, either version 3 of the License, or |
||||
(at your option) any later version. |
||||
|
||||
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. |
||||
*/ |
||||
|
||||
#include "port.h" |
||||
|
||||
#ifdef XASH_SDL |
||||
#include <SDL_main.h> |
||||
#include <SDL_messagebox.h> |
||||
#endif |
||||
|
||||
#include <stdio.h> |
||||
#include <string.h> |
||||
#include <stdlib.h> |
||||
#include <stdarg.h> |
||||
|
||||
#if defined(__APPLE__) || defined(__unix__) |
||||
#define XASHLIB "libxash." OS_LIB_EXT |
||||
#elif _WIN32 |
||||
#if !__MINGW32__ && _MSC_VER >= 1200 |
||||
#define USE_WINMAIN |
||||
#endif |
||||
#ifndef XASH_DEDICATED |
||||
#define XASHLIB "xash_sdl.dll" |
||||
#else |
||||
#define XASHLIB "xash_dedicated.dll" |
||||
#endif |
||||
#include <windows.h> |
||||
#endif |
||||
|
||||
#ifdef WIN32 |
||||
extern "C" |
||||
{ |
||||
// Enable NVIDIA High Performance Graphics while using Integrated Graphics.
|
||||
__declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; |
||||
|
||||
// Enable AMD High Performance Graphics while using Integrated Graphics.
|
||||
__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; |
||||
} |
||||
#endif |
||||
|
||||
#define GAME_PATH "valve" // default dir to start from
|
||||
|
||||
typedef void (*pfnChangeGame)( const char *progname ); |
||||
typedef int (*pfnInit)( int argc, char **argv, const char *progname, int bChangeGame, pfnChangeGame func ); |
||||
typedef void (*pfnShutdown)( void ); |
||||
|
||||
static pfnInit Xash_Main; |
||||
static pfnShutdown Xash_Shutdown = NULL; |
||||
static char szGameDir[128]; // safe place to keep gamedir
|
||||
static int szArgc; |
||||
static char **szArgv; |
||||
static HINSTANCE hEngine; |
||||
|
||||
static void Xash_Error( const char *szFmt, ... ) |
||||
{ |
||||
static char buffer[16384]; // must support > 1k messages
|
||||
va_list args; |
||||
|
||||
va_start( args, szFmt ); |
||||
vsnprintf( buffer, sizeof(buffer), szFmt, args ); |
||||
va_end( args ); |
||||
|
||||
#ifdef XASH_SDL |
||||
SDL_ShowSimpleMessageBox( SDL_MESSAGEBOX_ERROR, "Xash Error", buffer, NULL ); |
||||
#elif defined( _WIN32 ) |
||||
MessageBoxA( NULL, buffer, "Xash Error", MB_OK ); |
||||
#else |
||||
fprintf( stderr, "Xash Error: %s\n", buffer ); |
||||
#endif |
||||
exit( 1 ); |
||||
} |
||||
|
||||
#ifdef _WIN32 |
||||
static const char *GetStringLastError() |
||||
{ |
||||
static char buf[1024]; |
||||
|
||||
FormatMessageA( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, |
||||
NULL, GetLastError(), MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT ), |
||||
buf, sizeof( buf ), NULL ); |
||||
|
||||
return buf; |
||||
} |
||||
#endif |
||||
|
||||
static void Sys_LoadEngine( void ) |
||||
{ |
||||
if(( hEngine = LoadLibrary( XASHLIB )) == NULL ) |
||||
{ |
||||
Xash_Error("Unable to load the " XASHLIB ": %s", dlerror() ); |
||||
} |
||||
|
||||
if(( Xash_Main = (pfnInit)GetProcAddress( hEngine, "Host_Main" )) == NULL ) |
||||
{ |
||||
Xash_Error( XASHLIB " missed 'Host_Main' export: %s", dlerror() ); |
||||
} |
||||
|
||||
// this is non-fatal for us but change game will not working
|
||||
Xash_Shutdown = (pfnShutdown)GetProcAddress( hEngine, "Host_Shutdown" ); |
||||
} |
||||
|
||||
static void Sys_UnloadEngine( void ) |
||||
{ |
||||
if( Xash_Shutdown ) Xash_Shutdown( ); |
||||
if( hEngine ) FreeLibrary( hEngine ); |
||||
|
||||
Xash_Main = NULL; |
||||
Xash_Shutdown = NULL; |
||||
} |
||||
|
||||
static void Sys_ChangeGame( const char *progname ) |
||||
{ |
||||
if( !progname || !progname[0] ) |
||||
Xash_Error( "Sys_ChangeGame: NULL gamedir" ); |
||||
|
||||
if( Xash_Shutdown == NULL ) |
||||
Xash_Error( "Sys_ChangeGame: missed 'Host_Shutdown' export\n" ); |
||||
|
||||
strncpy( szGameDir, progname, sizeof( szGameDir ) - 1 ); |
||||
|
||||
Sys_UnloadEngine (); |
||||
Sys_LoadEngine (); |
||||
|
||||
Xash_Main( szArgc, szArgv, szGameDir, 1, Sys_ChangeGame ); |
||||
} |
||||
|
||||
_inline int Sys_Start( void ) |
||||
{ |
||||
int ret; |
||||
|
||||
Sys_LoadEngine(); |
||||
ret = Xash_Main( szArgc, szArgv, GAME_PATH, 0, Xash_Shutdown ? Sys_ChangeGame : NULL ); |
||||
Sys_UnloadEngine(); |
||||
|
||||
return ret; |
||||
} |
||||
|
||||
#ifndef USE_WINMAIN |
||||
int main( int argc, char **argv ) |
||||
{ |
||||
szArgc = argc; |
||||
szArgv = argv; |
||||
|
||||
return Sys_Start(); |
||||
} |
||||
#else |
||||
//#pragma comment(lib, "shell32.lib")
|
||||
int __stdcall WinMain( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdLine, int nShow ) |
||||
{ |
||||
LPWSTR* lpArgv; |
||||
int ret, i; |
||||
|
||||
lpArgv = CommandLineToArgvW( GetCommandLineW(), &szArgc ); |
||||
szArgv = ( char** )malloc( szArgc * sizeof( char* )); |
||||
|
||||
for( i = 0; i < szArgc; ++i ) |
||||
{ |
||||
int size = wcslen(lpArgv[i]) + 1; |
||||
szArgv[i] = ( char* )malloc( size ); |
||||
wcstombs( szArgv[i], lpArgv[i], size ); |
||||
} |
||||
|
||||
LocalFree( lpArgv ); |
||||
|
||||
ret = Sys_Start(); |
||||
|
||||
for( ; i < szArgc; ++i ) |
||||
free( szArgv[i] ); |
||||
free( szArgv ); |
||||
|
||||
return ret; |
||||
} |
||||
#endif |
@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
|
||||
#include <winver.h> |
||||
|
||||
#define IDI_ICON1 101 |
||||
|
||||
#define VER_FILEVERSION 1,00 |
||||
#define VER_FILEVERSION_STR "1.00" |
||||
#define VER_PRODUCTVERSION 1,00 |
||||
#define VER_PRODUCTVERSION_STR "1.00" |
||||
|
||||
#define VER_FILEFLAGSMASK VS_FF_PRERELEASE | VS_FF_PATCHED |
||||
#define VER_FILEFLAGS VS_FF_PRERELEASE |
||||
#define VER_FILEOS VOS__WINDOWS32 |
||||
#define VER_FILETYPE VFT_DLL |
||||
#define VER_FILESUBTYPE VFT2_UNKNOWN |
||||
|
||||
#define VER_COMPANYNAME_STR "Flying With Gauss" |
||||
#define VER_LEGALCOPYRIGHT_STR "Flying With Gauss" |
||||
#define VER_PRODUCTNAME_STR "Xash3D Launcher" |
||||
|
||||
#define VER_ANSICP |
||||
|
||||
#define VER_FILEDESCRIPTION_STR "Xash3D FWGS Launcher" |
||||
#define VER_ORIGINALFILENAME_STR "xash.exe" |
||||
#define VER_INTERNALNAME_STR "xash" |
||||
|
||||
#include <common.ver> |
||||
|
||||
IDI_ICON1 ICON DISCARDABLE "icon-xash-material.ico" |
After Width: | Height: | Size: 361 KiB |
After Width: | Height: | Size: 70 KiB |
@ -0,0 +1,58 @@
@@ -0,0 +1,58 @@
|
||||
#! /usr/bin/env python |
||||
# encoding: utf-8 |
||||
# a1batross, mittorn, 2018 |
||||
|
||||
from waflib import Logs |
||||
import os |
||||
|
||||
top = '.' |
||||
|
||||
def options(opt): |
||||
# stub |
||||
return |
||||
|
||||
def configure(conf): |
||||
if(conf.env.SINGLE_BINARY): |
||||
return |
||||
|
||||
# check for dedicated server build |
||||
if conf.env.DEST_OS != 'win32' and not conf.env.DEDICATED: |
||||
# TODO: add way to specify SDL2 path, move to separate function |
||||
try: |
||||
conf.check_cfg( |
||||
path='sdl2-config', |
||||
args='--cflags --libs', |
||||
package='', |
||||
msg='Checking for SDL2', |
||||
uselib_store='SDL2') |
||||
except conf.errors.ConfigurationError: |
||||
conf.fatal('SDL2 not availiable! If you want to build dedicated server, specify --dedicated') |
||||
conf.env.append_unique('DEFINES', 'XASH_SDL') |
||||
|
||||
def get_subproject_name(ctx): |
||||
return os.path.basename(os.path.realpath(str(ctx.path))) |
||||
|
||||
def build(bld): |
||||
bld.load_envs() |
||||
bld.env = bld.all_envs[get_subproject_name(bld)] |
||||
|
||||
source = 'game.cpp' |
||||
includes = '. ../common' |
||||
libs = [] |
||||
|
||||
if bld.env.DEST_OS != 'win32': |
||||
libs += [ 'DL' ] |
||||
if not bld.env.DEDICATED: |
||||
libs += [ 'SDL2' ] |
||||
else: |
||||
# compile resource on Windows |
||||
bld.load('winres') |
||||
source += 'game.rc' |
||||
|
||||
bld( |
||||
source = source, |
||||
target = 'xash3d', # hl.exe |
||||
features = 'c cprogram', |
||||
includes = includes, |
||||
use = libs |
||||
) |
@ -0,0 +1,70 @@
@@ -0,0 +1,70 @@
|
||||
#! /usr/bin/env python |
||||
# encoding: utf-8 |
||||
# mittorn, 2018 |
||||
|
||||
from waflib import Logs |
||||
import os |
||||
|
||||
top = '.' |
||||
|
||||
def options(opt): |
||||
opt.add_option( |
||||
'--vgui', action = 'store', type='string', dest = 'VGUI_DEV', |
||||
help = 'path to vgui-dev repo', default='' ) |
||||
|
||||
# stub |
||||
return |
||||
|
||||
def configure(conf): |
||||
if conf.options.DEDICATED: |
||||
return |
||||
|
||||
if not conf.options.VGUI_DEV: |
||||
conf.fatal("Provide a path to vgui-dev repository using --vgui key") |
||||
|
||||
if conf.env.DEST_CPU != 'x86' and not (conf.env.DEST_CPU == 'x86_64' and not conf.options.ALLOW64): # multilib case |
||||
conf.fatal('vgui is not supported on this CPU: ' + conf.env.DEST_CPU) |
||||
|
||||
if conf.env.DEST_OS == 'win32': |
||||
conf.env.LIB_VGUI = ['vgui.lib'] |
||||
conf.env.LIBPATH_VGUI = [os.path.abspath(os.path.join(conf.options.VGUI_DEV, 'lib/win32_vc6/'))] |
||||
else: |
||||
if conf.env.DEST_OS == 'linux': |
||||
conf.env.LIB_VGUI = [':vgui.so'] |
||||
elif conf.env.DEST_OS == 'darwin': |
||||
conf.env.LIB_VGUI = ['vgui.dylib'] |
||||
else: |
||||
conf.fatal('vgui is not supported on this OS: ' + conf.env.DEST_OS) |
||||
conf.env.LIBPATH_VGUI = [os.path.abspath(os.path.join(conf.options.VGUI_DEV, 'lib'))] |
||||
conf.env.INCLUDES_VGUI = [os.path.abspath(os.path.join(conf.options.VGUI_DEV, 'include'))] |
||||
|
||||
conf.env.HAVE_VGUI = 1 |
||||
|
||||
Logs.info('VGUI configured as {0}, {1}, {2}'.format(conf.env.LIB_VGUI, conf.env.LIBPATH_VGUI, conf.env.INCLUDES_VGUI)) |
||||
|
||||
def get_subproject_name(ctx): |
||||
return os.path.basename(os.path.realpath(str(ctx.path))) |
||||
|
||||
def build(bld): |
||||
bld.load_envs() |
||||
bld.env = bld.all_envs[get_subproject_name(bld)] |
||||
|
||||
if bld.env.DEDICATED: |
||||
return |
||||
|
||||
# basic build: dedicated only, no dependencies |
||||
if bld.env.DEST_OS != 'win32': |
||||
libs = [ 'DL', 'M' ] |
||||
|
||||
libs.append('VGUI') |
||||
|
||||
source = bld.path.ant_glob(['*.cpp']) |
||||
|
||||
includes = [ '.', '../common', '../engine' ] |
||||
|
||||
bld.shlib( |
||||
source = source, |
||||
target = 'vgui_support', |
||||
features = 'cxx', |
||||
includes = includes, |
||||
use = libs) |
@ -0,0 +1,97 @@
@@ -0,0 +1,97 @@
|
||||
#! /usr/bin/env python |
||||
# encoding: utf-8 |
||||
# a1batross, mittorn, 2018 |
||||
|
||||
from __future__ import print_function |
||||
from waflib import Logs |
||||
|
||||
import os |
||||
import sys |
||||
|
||||
def get_git_version(): |
||||
# try grab the current version number from git |
||||
version = "notset" |
||||
if os.path.exists(".git"): |
||||
try: |
||||
version = os.popen("git describe --dirty --always").read().strip() |
||||
except Exception as e: |
||||
print(e) |
||||
return version |
||||
|
||||
VERSION = '0.99' |
||||
APPNAME = 'xash3d-fwgs' |
||||
GIT_SHA = get_git_version() |
||||
SUBDIRS = [ 'game_launch', 'vgui_support', 'engine' ] |
||||
|
||||
top = '.' |
||||
|
||||
def options(opt): |
||||
opt.load('compiler_cxx compiler_c') |
||||
if sys.platform == 'win32': |
||||
opt.load('msvc') |
||||
|
||||
opt.add_option( |
||||
'--dedicated', action = 'store_true', dest = 'DEDICATED', default=False, |
||||
help = 'build Xash Dedicated Server(XashDS)') |
||||
|
||||
opt.add_option( |
||||
'--64bits', action = 'store_true', dest = 'ALLOW64', default=False, |
||||
help = 'allow targetting 64-bit engine') |
||||
|
||||
opt.add_option( |
||||
'--release', action = 'store_true', dest = 'RELEASE', default=False, |
||||
help = 'strip debug info from binary and enable optimizations') |
||||
|
||||
opt.recurse(SUBDIRS) |
||||
|
||||
def configure(conf): |
||||
conf.load('compiler_cxx compiler_c') |
||||
conf.check_cc( |
||||
fragment=''' |
||||
#include <stdio.h> |
||||
int main( void ) { printf("%ld", sizeof( void * )); return 0; } |
||||
''', |
||||
execute = True, |
||||
define_ret = True, |
||||
uselib_store = 'SIZEOF_VOID_P', |
||||
msg = 'Checking sizeof(void*)') |
||||
|
||||
if(conf.env.SIZEOF_VOID_P != '4' and not conf.options.ALLOW64): |
||||
conf.env.append_value('LINKFLAGS', '-m32') |
||||
conf.env.append_value('CFLAGS', '-m32') |
||||
conf.env.append_value('CXXFLAGS', '-m32') |
||||
Logs.info('NOTE: will build engine with 64-bit toolchain using -m32') |
||||
else: |
||||
Logs.warn('WARNING: 64-bit engine may be unstable') |
||||
|
||||
if(conf.env.COMPILER_CC == 'gcc'): |
||||
conf.env.append_value('LINKFLAGS', '-Wl,--no-undefined') |
||||
|
||||
if(conf.options.RELEASE): |
||||
conf.env.append_unique('CFLAGS', '-O2') |
||||
else: |
||||
conf.env.append_unique('CFLAGS', '-Og') |
||||
conf.env.append_unique('CFLAGS', '-g') |
||||
|
||||
|
||||
conf.check( lib='dl' ) |
||||
conf.check( lib='m' ) |
||||
conf.check( lib='pthread' ) |
||||
|
||||
conf.env.DEDICATED = conf.options.DEDICATED |
||||
conf.env.SINGLE_BINARY = conf.options.DEDICATED |
||||
|
||||
# global |
||||
conf.env.append_unique('XASH_BUILD_COMMIT', GIT_SHA) |
||||
|
||||
for i in SUBDIRS: |
||||
conf.setenv(i, conf.env) # derive new env from global one |
||||
conf.env.ENVNAME = i |
||||
Logs.info('Configuring ' + i) |
||||
# configure in standalone env |
||||
conf.recurse(i) |
||||
conf.setenv('') |
||||
|
||||
def build(bld): |
||||
for i in SUBDIRS: |
||||
bld.recurse(SUBDIRS) |
Loading…
Reference in new issue