From de12f64c146e49bc49f2e3b3cbbe31b1ca81f3fe Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Sat, 13 Dec 2014 19:39:44 -0500 Subject: [PATCH 01/10] Convert CPlayer::m_AuthID to ke::AString. --- core/PlayerManager.cpp | 14 +++++++------- core/PlayerManager.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/core/PlayerManager.cpp b/core/PlayerManager.cpp index 9d9e0a4b..6707da59 100644 --- a/core/PlayerManager.cpp +++ b/core/PlayerManager.cpp @@ -405,7 +405,7 @@ void PlayerManager::RunAuthChecks() pPlayer = &m_Players[m_AuthQueue[i]]; pPlayer->UpdateAuthIds(); - authstr = pPlayer->m_AuthID.c_str(); + authstr = pPlayer->m_AuthID.chars(); if (!pPlayer->IsAuthStringValidated()) { @@ -717,14 +717,14 @@ void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername for (iter=m_hooks.begin(); iter!=m_hooks.end(); iter++) { pListener = (*iter); - pListener->OnClientAuthorized(client, steamId ? steamId : pPlayer->m_AuthID.c_str()); + pListener->OnClientAuthorized(client, steamId ? steamId : pPlayer->m_AuthID.chars()); } /* Finally, tell plugins */ if (m_clauth->GetFunctionCount()) { m_clauth->PushCell(client); /* For legacy reasons, people are expecting the Steam2 id here if using Steam auth */ - m_clauth->PushString(steamId ? steamId : pPlayer->m_AuthID.c_str()); + m_clauth->PushString(steamId ? steamId : pPlayer->m_AuthID.chars()); m_clauth->Execute(NULL); } pPlayer->Authorize_Post(); @@ -2001,7 +2001,7 @@ void CPlayer::UpdateAuthIds() #else authstr = engine->GetPlayerNetworkIDString(m_pEdict); #endif - m_AuthID.assign(authstr); + m_AuthID = authstr; // Then, cache SteamId if (IsFakeClient()) @@ -2097,7 +2097,7 @@ void CPlayer::Disconnect() m_IsAuthorized = false; m_Name.clear(); m_Ip.clear(); - m_AuthID.clear(); + m_AuthID = ""; m_SteamId = k_steamIDNil; m_Steam2Id = ""; m_Steam3Id = ""; @@ -2142,7 +2142,7 @@ const char *CPlayer::GetAuthString(bool validated) return NULL; } - return m_AuthID.c_str(); + return m_AuthID.chars(); } const CSteamID &CPlayer::GetSteamId(bool validated) @@ -2451,7 +2451,7 @@ void CPlayer::DoBasicAdminChecks() } /* Check steam id */ - if ((id = adminsys->FindAdminByIdentity("steam", m_AuthID.c_str())) != INVALID_ADMIN_ID) + if ((id = adminsys->FindAdminByIdentity("steam", m_AuthID.chars())) != INVALID_ADMIN_ID) { if (g_Players.CheckSetAdmin(client, this, id)) { diff --git a/core/PlayerManager.h b/core/PlayerManager.h index 22ca01fc..3f78c9f8 100644 --- a/core/PlayerManager.h +++ b/core/PlayerManager.h @@ -123,7 +123,7 @@ private: String m_Name; String m_Ip; String m_IpNoPort; - String m_AuthID; + ke::AString m_AuthID; ke::AString m_Steam2Id; ke::AString m_Steam3Id; AdminId m_Admin; From d51a57cc34ed1f740d0b736e746d56244e6624af Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Sat, 13 Dec 2014 19:40:22 -0500 Subject: [PATCH 02/10] In UpdatePlayerAuth, don't update SteamIDs if AuthID hasn't changed. --- core/PlayerManager.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/PlayerManager.cpp b/core/PlayerManager.cpp index 6707da59..8cccbc11 100644 --- a/core/PlayerManager.cpp +++ b/core/PlayerManager.cpp @@ -2001,6 +2001,11 @@ void CPlayer::UpdateAuthIds() #else authstr = engine->GetPlayerNetworkIDString(m_pEdict); #endif + if (m_AuthID.compare(authstr) == 0) + { + return; + } + m_AuthID = authstr; // Then, cache SteamId From 67fcd9e2c6db9ce0ba4ef622e75884e3be71ce5b Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Sun, 14 Dec 2014 14:56:19 -0500 Subject: [PATCH 03/10] Populate auth ids (if available) when initializing CPlayer instance. --- core/PlayerManager.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/PlayerManager.cpp b/core/PlayerManager.cpp index 8cccbc11..0978eb90 100644 --- a/core/PlayerManager.cpp +++ b/core/PlayerManager.cpp @@ -1963,6 +1963,8 @@ void CPlayer::Initialize(const char *name, const char *ip, edict_t *pEntity) *ptr = '\0'; } m_IpNoPort.assign(ip2); + + UpdateAuthIds(); } void CPlayer::Connect() From 03abafce3dd55309fd6cc054ed19bb79da453da2 Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Sun, 14 Dec 2014 14:59:16 -0500 Subject: [PATCH 04/10] Change /d2Zi+ flag on msvc builds to /Zo. http://msdn.microsoft.com/en-us/library/dn785163.aspx --- AMBuildScript | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/AMBuildScript b/AMBuildScript index 580b0807..fe92d4fd 100644 --- a/AMBuildScript +++ b/AMBuildScript @@ -256,9 +256,7 @@ class SMConfig(object): if builder.options.debug == '1': cxx.defines += ['DEBUG', '_DEBUG'] if cxx.like('msvc'): - cxx.cflags += ['/Od', '/RTC1'] - if cxx.version >= 1600: - cxx.cflags += ['/d2Zi+'] + cxx.cflags += ['/Od', '/Zo', '/RTC1'] # This needs to be after our optimization flags which could otherwise disable it. if cxx.vendor == 'msvc': From 7e8473b61a7f0cb1ace14c000c94ce7e67577ef7 Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Sun, 14 Dec 2014 16:03:42 -0500 Subject: [PATCH 05/10] Remove /Zo on debug builds and add on release builds. --- AMBuildScript | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AMBuildScript b/AMBuildScript index fe92d4fd..d2b99d54 100644 --- a/AMBuildScript +++ b/AMBuildScript @@ -249,14 +249,14 @@ class SMConfig(object): if cxx.like('gcc'): cxx.cflags += ['-O3'] elif cxx.like('msvc'): - cxx.cflags += ['/Ox'] + cxx.cflags += ['/Ox', '/Zo'] cxx.linkflags += ['/OPT:ICF', '/OPT:REF'] # Debugging if builder.options.debug == '1': cxx.defines += ['DEBUG', '_DEBUG'] if cxx.like('msvc'): - cxx.cflags += ['/Od', '/Zo', '/RTC1'] + cxx.cflags += ['/Od', '/RTC1'] # This needs to be after our optimization flags which could otherwise disable it. if cxx.vendor == 'msvc': From 844fad263ae5a78a064467c80c60b653f22add2b Mon Sep 17 00:00:00 2001 From: Ross Bemrose Date: Tue, 16 Dec 2014 16:06:20 -0500 Subject: [PATCH 06/10] Add new-style API compatibility for VoteHandler. --- plugins/include/menus.inc | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/plugins/include/menus.inc b/plugins/include/menus.inc index 22ba0a09..c85b07f2 100644 --- a/plugins/include/menus.inc +++ b/plugins/include/menus.inc @@ -810,14 +810,28 @@ stock bool VoteMenuToAll(Handle menu, int time, int flags=0) * @param item_info Array of items, sorted by count. Use VOTEINFO_ITEM * defines. */ -typedef VoteHandler = function void ( - Menu menu, - int num_votes, - int num_clients, - const int client_info[][2], - int num_items, - const int item_info[][2] -); +typeset VoteHandler +{ + // old style + function void( + Menu menu, + int num_votes, + int num_clients, + const int client_info[][2], + int num_items, + const int item_info[][2] + ); + + // new style + function void( + Menu menu, + int num_votes, + int num_clients, + const int[][] client_info, + int num_items, + const int[][] item_info + ); +}; /** * Sets an advanced vote handling callback. If this callback is set, From 154d84668b37c3051148b3df1568aa5e067ee281 Mon Sep 17 00:00:00 2001 From: Ryan Stecker Date: Wed, 17 Dec 2014 16:23:33 -0600 Subject: [PATCH 07/10] Old style retagging should emit a compiler warning when newdecls are required. --- sourcepawn/compiler/sc3.cpp | 6 +++++- sourcepawn/compiler/sc5-in.scp | 1 + .../compiler/tests/warn-oldstyle-cast.sp | 18 ++++++++++++++++++ .../compiler/tests/warn-oldstyle-cast.txt | 2 ++ 4 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 sourcepawn/compiler/tests/warn-oldstyle-cast.sp create mode 100644 sourcepawn/compiler/tests/warn-oldstyle-cast.txt diff --git a/sourcepawn/compiler/sc3.cpp b/sourcepawn/compiler/sc3.cpp index 7b5e6d00..d247978e 100644 --- a/sourcepawn/compiler/sc3.cpp +++ b/sourcepawn/compiler/sc3.cpp @@ -334,7 +334,7 @@ const char *type_to_name(int tag) const char *name = pc_tagname(tag); if (name) - return "unknown"; + return name; if (tag & FUNCTAG) return "function"; @@ -1698,6 +1698,10 @@ static int hier2(value *lval) } case tLABEL: /* tagname override */ tag=pc_addtag(st); + if (sc_require_newdecls) { + // Warn: old style cast used when newdecls pragma is enabled + error(240, st, type_to_name(tag)); + } lval->cmptag=tag; lvalue=hier2(lval); if ((lval->tag & OBJECTTAG) || (tag & OBJECTTAG)) { diff --git a/sourcepawn/compiler/sc5-in.scp b/sourcepawn/compiler/sc5-in.scp index 064ffd4b..0c8d1528 100644 --- a/sourcepawn/compiler/sc5-in.scp +++ b/sourcepawn/compiler/sc5-in.scp @@ -462,6 +462,7 @@ static const char *warnmsg[] = { /*237*/ "coercing functions to and from primitives is unsupported and will be removed in the future\n", /*238*/ "'%s:' is an illegal cast; use view_as<%s>(expression)\n", /*239*/ "'%s' is an illegal tag; use %s as a type\n", +/*240*/ "'%s:' is an old-style tag operation; use view_as<%s>(expression) instead\n", #else "\327 \275tr\242\231\227\266 %\204\305\206a\306\210\260", "\214\343i\215 \330\371\213t/\321cro \365", diff --git a/sourcepawn/compiler/tests/warn-oldstyle-cast.sp b/sourcepawn/compiler/tests/warn-oldstyle-cast.sp new file mode 100644 index 00000000..5f6c899c --- /dev/null +++ b/sourcepawn/compiler/tests/warn-oldstyle-cast.sp @@ -0,0 +1,18 @@ + +#pragma newdecls required + +enum MyType:{}; + +native void Print(MyType value); +native void PrintF(float value); + +public void main() +{ + int val = 2; + MyType otherVal = MyType:val; + + float value2 = Float:val; + + Print(otherVal); + PrintF(value2); +} diff --git a/sourcepawn/compiler/tests/warn-oldstyle-cast.txt b/sourcepawn/compiler/tests/warn-oldstyle-cast.txt new file mode 100644 index 00000000..21696a51 --- /dev/null +++ b/sourcepawn/compiler/tests/warn-oldstyle-cast.txt @@ -0,0 +1,2 @@ +(12) : warning 240: 'MyType:' is an old-style tag operation; use view_as(expression) instead +(14) : warning 240: 'Float:' is an old-style tag operation; use view_as(expression) instead From 4311dc32705f6331e1c5b8a33c1a191f0b88238e Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Thu, 18 Dec 2014 04:55:58 -0800 Subject: [PATCH 08/10] Bump version to 1.8.0-dev. --- plugins/include/version.inc | 4 ++-- product.version | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/include/version.inc b/plugins/include/version.inc index 7a9d876c..8519560a 100644 --- a/plugins/include/version.inc +++ b/plugins/include/version.inc @@ -42,8 +42,8 @@ #define SOURCEMOD_V_REV 0 #define SOURCEMOD_V_CSET "0" #define SOURCEMOD_V_MAJOR 1 /**< SourceMod Major version */ -#define SOURCEMOD_V_MINOR 7 /**< SourceMod Minor version */ +#define SOURCEMOD_V_MINOR 8 /**< SourceMod Minor version */ #define SOURCEMOD_V_RELEASE 0 /**< SourceMod Release version */ -#define SOURCEMOD_VERSION "1.7.0-manual" /**< SourceMod version string (major.minor.release-tag) */ +#define SOURCEMOD_VERSION "1.8.0-manual" /**< SourceMod version string (major.minor.release-tag) */ #endif diff --git a/product.version b/product.version index de023c91..0ef074f2 100644 --- a/product.version +++ b/product.version @@ -1 +1 @@ -1.7.0-dev +1.8.0-dev From 13f6e2d4d0a411087daa104b0a0f683c8931f286 Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Thu, 18 Dec 2014 05:09:25 -0800 Subject: [PATCH 09/10] Trigger build. --- pushbuild.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pushbuild.txt b/pushbuild.txt index 0ffb229f..511bdab8 100644 --- a/pushbuild.txt +++ b/pushbuild.txt @@ -3,7 +3,7 @@ joys of buildbot, part 2: buildbot and the very lonely square-shaped duck joys of buildbot, part 3: an accidental event proves troublesome for a psychic fish joys of buildbot, part 4: a transient mummy is perplexed by a broken wand buildbot has horrible blugs -i am the very model of a modern major general +I am the very model of a modern major general It's no wonder the build always falls over when we call it pushing. h i From 679b2863fa10129187d251f6bfcd8b28170b92cd Mon Sep 17 00:00:00 2001 From: Ryan Stecker Date: Thu, 18 Dec 2014 18:18:55 -0600 Subject: [PATCH 10/10] Update manual builds to use version 1.8.0 --- public/sourcemod_version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/sourcemod_version.h b/public/sourcemod_version.h index caa88ea3..bb30ee2d 100644 --- a/public/sourcemod_version.h +++ b/public/sourcemod_version.h @@ -52,13 +52,13 @@ #define SM_BUILD_LOCAL_REV "0" #define SM_BUILD_CSET "0" #define SM_BUILD_MAJOR "1" -#define SM_BUILD_MINOR "7" +#define SM_BUILD_MINOR "8" #define SM_BUILD_RELEASE "0" #define SM_BUILD_UNIQUEID SM_BUILD_LOCAL_REV ":" SM_BUILD_CSET #define SM_VERSION_STRING SM_BUILD_MAJOR "." SM_BUILD_MINOR "." SM_BUILD_RELEASE "-" SM_BUILD_TAG -#define SM_VERSION_FILE 1,7,0,0 +#define SM_VERSION_FILE 1,8,0,0 #endif #define SM_BUILD_TIMESTAMP __DATE__ " " __TIME__