2
0
mirror of https://github.com/rehlds/reapi.git synced 2025-01-01 01:25:47 +03:00

Fixed the crashing caused by incorrect copy a mapname.

Update PreBuild.bat
This commit is contained in:
s1lentq 2017-01-06 12:39:05 +07:00
parent 65083757b2
commit adb34bb0ed
2 changed files with 55 additions and 20 deletions

View File

@ -8,6 +8,7 @@ set srcdir=%~1
set repodir=%~2 set repodir=%~2
set old_version= set old_version=
set old_version_inc=
set version_major=0 set version_major=0
set version_minor=0 set version_minor=0
set version_maintenance=0 set version_maintenance=0
@ -49,6 +50,21 @@ IF EXIST "%srcdir%\appversion.h" (
) )
) )
::
:: Read old reapi_version.inc, if present
::
IF EXIST "%srcdir%\reapi_version.inc" (
FOR /F "usebackq tokens=1,2,3" %%i in ("%srcdir%\reapi_version.inc") do (
IF %%i==#define (
IF %%j==REAPI_VERSION (
:: Remove quotes
set v=%%k
set old_version_inc=!v:"=!
)
)
)
)
IF %errlvl% == "1" ( IF %errlvl% == "1" (
echo can't locate git.exe - auto-versioning step won't be performed echo can't locate git.exe - auto-versioning step won't be performed
@ -165,8 +181,36 @@ IF [%localChanged%]==[1] (
) )
:: ::
:: Update reapi_version.inc :: Now form full version string like 1.0.0.1
:: ::
set new_version_inc=%version_major%%version_minor%%commitCount%
set new_version=%version_major%.%version_minor%.%version_maintenance%.%commitCount%-dev%version_modifed%
::
:: Update appversion.h if version has changed or modifications/mixed revisions detected
::
IF NOT "%new_version%"=="%old_version%" (
goto _update
)
::
:: Update reapi_version.inc if version has changed or modifications/mixed revisions detected
::
IF NOT "%new_version_inc%"=="%old_version_inc%" (
goto _update
)
goto _exit
:_update
::
:: Write reapi_version.inc
::
echo Updating reapi_version.inc, new version is "%new_version_inc%", the old one was %old_version_inc%
echo #if defined _reapi_version_included>"%srcdir%\reapi_version.inc" echo #if defined _reapi_version_included>"%srcdir%\reapi_version.inc"
echo #endinput>>"%srcdir%\reapi_version.inc" echo #endinput>>"%srcdir%\reapi_version.inc"
echo #endif>>"%srcdir%\reapi_version.inc" echo #endif>>"%srcdir%\reapi_version.inc"
@ -179,22 +223,9 @@ echo.>>"%srcdir%\reapi_version.inc"
>>"%srcdir%\reapi_version.inc" echo #define REAPI_VERSION_MINOR %version_minor% >>"%srcdir%\reapi_version.inc" echo #define REAPI_VERSION_MINOR %version_minor%
:: ::
:: Now form full version string like 1.0.0.1 :: Write appversion.h
:: ::
echo Updating appversion.h, new version is "%new_version%", the old one was %old_version%
set new_version=%version_major%.%version_minor%.%version_maintenance%.%commitCount%-dev%version_modifed%
::
:: Update appversion.h if version has changed or modifications/mixed revisions detected
::
IF NOT "%new_version%"=="%old_version%" (
goto _update
)
goto _exit
:_update
echo Updating appversion.h and reapi_version.inc, new version is "%new_version%", the old one was %old_version%
echo #ifndef __APPVERSION_H__>"%srcdir%\appversion.h" echo #ifndef __APPVERSION_H__>"%srcdir%\appversion.h"
echo #define __APPVERSION_H__>>"%srcdir%\appversion.h" echo #define __APPVERSION_H__>>"%srcdir%\appversion.h"

View File

@ -2,7 +2,7 @@
edict_t* g_pEdicts; edict_t* g_pEdicts;
playermove_t* g_pMove; playermove_t* g_pMove;
char g_szMapName[32]; char g_szMapName[32] = "";
int gmsgSendAudio, gmsgStatusIcon, gmsgArmorType, gmsgItemStatus, gmsgBarTime, gmsgBarTime2; int gmsgSendAudio, gmsgStatusIcon, gmsgArmorType, gmsgItemStatus, gmsgBarTime, gmsgBarTime2;
struct struct
@ -24,9 +24,13 @@ void OnAmxxAttach()
api_cfg.Init(); api_cfg.Init();
g_pEdicts = g_engfuncs.pfnPEntityOfEntIndex(0); g_pEdicts = g_engfuncs.pfnPEntityOfEntIndex(0);
// If AMXX_Attach been called in a first the event Spawn
if (g_pEdicts)
{
// save true mapname // save true mapname
strncpy(g_szMapName, STRING(gpGlobals->mapname), sizeof(g_szMapName) - 1); strncpy(g_szMapName, STRING(gpGlobals->mapname), sizeof(g_szMapName) - 1);
g_szMapName[sizeof(g_szMapName) - 1] = '\0'; g_szMapName[sizeof(g_szMapName) - 1] = '\0';
}
} }
bool OnMetaAttach() bool OnMetaAttach()