Skip to content

Conversation

@geominorai
Copy link
Contributor

@geominorai geominorai commented Jun 17, 2018

Converted all pre-transitional code to comply with new SM syntax
Code has also been refactored to use method maps and their updated callbacks where applicable
A few DataPack memory leaks were also patched and minor code styles tidied up

Description

Method map usage include:

  • AdminId
  • ArrayList
  • ConVar
  • Database
  • DataPack
  • DBResultSet
  • File
  • KeyValues
  • Menu
  • Panel
  • SMCParser
  • TopMenu

Motivation and Context

Improve readability with syntax standardization for ease of future debugging and development.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Compiler requirements have been upped to SM 1.7+. All compatibility legacy code for pre-transitional syntax compilers have been removed.

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.

@Groruk Groruk requested review from Groruk and rumblefrog June 17, 2018 13:58
Copy link
Member

@rumblefrog rumblefrog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job 👍 Just need few edits

#if SOURCEMOD_V_MAJOR >= 1 && SOURCEMOD_V_MINOR >= 8
SetPackPosition(data, view_as<DataPackPos>(16));
dataPack.Position = view_as<DataPackPos>(16);
#else
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove the sourcemod version check and use the latest, moving forward we are only going to permit 1.8+

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Roger that.


#if defined DEBUG
decl String:auth[64];
cgar auth[64];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I too love cgar

if (gagState && gagLength == 0)
{
return ThrowNativeError(SP_ERROR_NATIVE, "Permanent gag is not allowed!");
ThrowNativeError(SP_ERROR_NATIVE, "Permanent gag is not allowed!");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All ThrowNativeError should return to stop the execution of the rest

Copy link
Contributor Author

@geominorai geominorai Jun 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch.

Copy link
Contributor

@CrazyHackGUT CrazyHackGUT Jun 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not required. Just compare implementations ThrowError() and ThrowNativeError().

// MENU CODE //

public void OnAdminMenuReady(Handle topmenu)
public void OnAdminMenuReady(Handle hTemp)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type could be TopMenu

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind on this, apparently Sourcemod still uses Handle as the type for this. This could be a separate PR to Sourcemod to change this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually can't compile this with TopMenu. Looks like the compiler's forcing the Handle in the prototype:
function argument named 'topmenu' differs from prototype

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's a PR to Sourcemod, for another day

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not TopMenu handle. This is generic handle. Check API.
https://sm.alliedmods.net/new-api/topmenus/TopMenu/FromHandle

public void OnAdminMenuReady(Handle topmenu)
public void OnAdminMenuReady(Handle hTemp)
{
TopMenu topmenu = view_as<TopMenu>(hTemp);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then this casting wouldn't be needed

Copy link
Member

@rumblefrog rumblefrog Jun 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind on this, apparently Sourcemod still uses Handle as the type for this. This could be a separate PR to Sourcemod to change this.

@rumblefrog rumblefrog mentioned this pull request Jun 17, 2018
4 tasks
@Groruk Groruk merged commit 89eb6f4 into sbpp:v1.x Jun 18, 2018
@geominorai
Copy link
Contributor Author

Thanks for taking the time to review this long commit guys. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants