Skip to content

Commit

Permalink
Rename PollOption to PollType
Browse files Browse the repository at this point in the history
  • Loading branch information
allejo committed Jan 27, 2017
1 parent c9cdba8 commit c15c18a
Show file tree
Hide file tree
Showing 14 changed files with 122 additions and 122 deletions.
36 changes: 18 additions & 18 deletions Xcode/BZFlag.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@
03FA74341742606400573D2D /* serverSidePlayerSample.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 03FA742E1742601B00573D2D /* serverSidePlayerSample.dylib */; };
03FA7435174260CB00573D2D /* playerHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF8950DD16E42CF800BA9DD5 /* playerHandler.cpp */; };
03FA7436174260D700573D2D /* serverSidePlayerSample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF8950DF16E42CF800BA9DD5 /* serverSidePlayerSample.cpp */; };
C333EFD41E2B9F5500B4B182 /* customPollOptionSample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C333EFCE1E2B9F5500B4B182 /* customPollOptionSample.cpp */; };
C333EFD41E2B9F5500B4B182 /* customPollTypeSample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C333EFCE1E2B9F5500B4B182 /* customPollTypeSample.cpp */; };
C353B1DB1AE23A0C00C5AED5 /* CustomZoneSample.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = C353B1D71AE239CC00C5AED5 /* CustomZoneSample.dylib */; };
C353B1E71AE23CA900C5AED5 /* CustomZoneSample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C353B1E01AE23C8100C5AED5 /* CustomZoneSample.cpp */; };
DF28982B16B4F5AE006C78AC /* ShotManager.cxx in Sources */ = {isa = PBXBuildFile; fileRef = DF28982916B4F5AE006C78AC /* ShotManager.cxx */; };
Expand Down Expand Up @@ -1731,9 +1731,9 @@
03E42D121B321DF2006EE763 /* data */ = {isa = PBXFileReference; lastKnownFileType = folder; name = data; path = ../data; sourceTree = "<group>"; };
03E42D191B322DFC006EE763 /* COPYING */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = COPYING; path = ../COPYING; sourceTree = "<group>"; };
03FA742E1742601B00573D2D /* serverSidePlayerSample.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = serverSidePlayerSample.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
C333EFC91E2B9F0800B4B182 /* customPollOptionSample.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = customPollOptionSample.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
C333EFCE1E2B9F5500B4B182 /* customPollOptionSample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = customPollOptionSample.cpp; sourceTree = "<group>"; };
C333EFD31E2B9F5500B4B182 /* README.customPollOptionSample.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.customPollOptionSample.txt; sourceTree = "<group>"; };
C333EFC91E2B9F0800B4B182 /* customPollTypeSample.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = customPollTypeSample.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
C333EFCE1E2B9F5500B4B182 /* customPollTypeSample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = customPollTypeSample.cpp; sourceTree = "<group>"; };
C333EFD31E2B9F5500B4B182 /* README.customPollTypeSample.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.customPollTypeSample.txt; sourceTree = "<group>"; };
C353B1D71AE239CC00C5AED5 /* CustomZoneSample.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = CustomZoneSample.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
C353B1E01AE23C8100C5AED5 /* CustomZoneSample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CustomZoneSample.cpp; sourceTree = "<group>"; };
C353B1E81AE2489900C5AED5 /* CustomZoneSample.bzw */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CustomZoneSample.bzw; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3008,7 +3008,7 @@
0315BEAF1B821C0700FC7CE0 /* bzfscron */,
0394E6E6167B1024007F4035 /* chathistory */,
0394E6EC167B1024007F4035 /* customflagsample */,
C333EFCD1E2B9F5500B4B182 /* customPollOptionSample */,
C333EFCD1E2B9F5500B4B182 /* customPollTypeSample */,
C353B1DF1AE23C8100C5AED5 /* CustomZoneSample */,
0394E6F3167B1024007F4035 /* fairCTF */,
0394E6FA167B1024007F4035 /* fastmap */,
Expand Down Expand Up @@ -3345,7 +3345,7 @@
0315BEAB1B821BFF00FC7CE0 /* bzfscron.dylib */,
0394E7F3167B1A17007F4035 /* chathistory.dylib */,
0394E7FE167B1E66007F4035 /* customflagsample.dylib */,
C333EFC91E2B9F0800B4B182 /* customPollOptionSample.dylib */,
C333EFC91E2B9F0800B4B182 /* customPollTypeSample.dylib */,
C353B1D71AE239CC00C5AED5 /* CustomZoneSample.dylib */,
0394E809167B1ECE007F4035 /* fairCTF.dylib */,
0394E814167B1F76007F4035 /* fastmap.dylib */,
Expand Down Expand Up @@ -3435,13 +3435,13 @@
name = Frameworks;
sourceTree = "<group>";
};
C333EFCD1E2B9F5500B4B182 /* customPollOptionSample */ = {
C333EFCD1E2B9F5500B4B182 /* customPollTypeSample */ = {
isa = PBXGroup;
children = (
C333EFCE1E2B9F5500B4B182 /* customPollOptionSample.cpp */,
C333EFD31E2B9F5500B4B182 /* README.customPollOptionSample.txt */,
C333EFCE1E2B9F5500B4B182 /* customPollTypeSample.cpp */,
C333EFD31E2B9F5500B4B182 /* README.customPollTypeSample.txt */,
);
path = customPollOptionSample;
path = customPollTypeSample;
sourceTree = "<group>";
};
C353B1DF1AE23C8100C5AED5 /* CustomZoneSample */ = {
Expand Down Expand Up @@ -4655,9 +4655,9 @@
productReference = 03FA742E1742601B00573D2D /* serverSidePlayerSample.dylib */;
productType = "com.apple.product-type.library.dynamic";
};
C333EFC81E2B9F0800B4B182 /* customPollOptionSample */ = {
C333EFC81E2B9F0800B4B182 /* customPollTypeSample */ = {
isa = PBXNativeTarget;
buildConfigurationList = C333EFCC1E2B9F0800B4B182 /* Build configuration list for PBXNativeTarget "customPollOptionSample" */;
buildConfigurationList = C333EFCC1E2B9F0800B4B182 /* Build configuration list for PBXNativeTarget "customPollTypeSample" */;
buildPhases = (
C333EFC51E2B9F0800B4B182 /* Sources */,
C333EFC61E2B9F0800B4B182 /* Frameworks */,
Expand All @@ -4667,9 +4667,9 @@
);
dependencies = (
);
name = customPollOptionSample;
productName = customPollOptionSample;
productReference = C333EFC91E2B9F0800B4B182 /* customPollOptionSample.dylib */;
name = customPollTypeSample;
productName = customPollTypeSample;
productReference = C333EFC91E2B9F0800B4B182 /* customPollTypeSample.dylib */;
productType = "com.apple.product-type.library.dynamic";
};
C353B1D61AE239CC00C5AED5 /* CustomZoneSample */ = {
Expand Down Expand Up @@ -4748,6 +4748,7 @@
0315BEAA1B821BFF00FC7CE0 /* bzfscron */,
0394E7F2167B1A17007F4035 /* chathistory */,
0394E7FD167B1E66007F4035 /* customflagsample */,
C333EFC81E2B9F0800B4B182 /* customPollTypeSample */,
C353B1D61AE239CC00C5AED5 /* CustomZoneSample */,
0394E808167B1ECE007F4035 /* fairCTF */,
0394E813167B1F76007F4035 /* fastmap */,
Expand Down Expand Up @@ -4775,7 +4776,6 @@
0394E91B167B293E007F4035 /* timedctf */,
0394E926167B29CC007F4035 /* TimeLimit */,
0394E93C167B2A9E007F4035 /* wwzones */,
C333EFC81E2B9F0800B4B182 /* customPollOptionSample */,
);
};
/* End PBXProject section */
Expand Down Expand Up @@ -5582,7 +5582,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
C333EFD41E2B9F5500B4B182 /* customPollOptionSample.cpp in Sources */,
C333EFD41E2B9F5500B4B182 /* customPollTypeSample.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -7964,7 +7964,7 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
C333EFCC1E2B9F0800B4B182 /* Build configuration list for PBXNativeTarget "customPollOptionSample" */ = {
C333EFCC1E2B9F0800B4B182 /* Build configuration list for PBXNativeTarget "customPollTypeSample" */ = {
isa = XCConfigurationList;
buildConfigurations = (
C333EFCA1E2B9F0800B4B182 /* Debug */,
Expand Down
12 changes: 6 additions & 6 deletions include/VotingArbiter.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,19 +366,19 @@ inline TimeKeeper VotingArbiter::getStartTime(void) const
return _startTime;
}

struct PollOption {
struct PollType {
std::string pollParameters;
bz_CustomPollOptionHandler* pollHandler;
bz_CustomPollTypeHandler* pollHandler;

PollOption() :
PollType() :
pollParameters(""), pollHandler(0)
{}
};

extern std::map<std::string, PollOption> customPollOptions;
extern std::map<std::string, PollType> customPollTypes;

void registerCustomPollOption ( const char* object, const char* parameters, bz_CustomPollOptionHandler *handler );
void removeCustomPollOption ( const char* object );
void registerCustomPollType ( const char* object, const char* parameters, bz_CustomPollTypeHandler *handler );
void removeCustomPollType ( const char* object );

#else
class VotingArbiter;
Expand Down
12 changes: 6 additions & 6 deletions include/bzfsAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -1617,18 +1617,18 @@ BZF_API bz_APIStringList *bz_getHelpTopic( std::string name );

// custom polls

class bz_CustomPollOptionHandler
class bz_CustomPollTypeHandler
{
public:
virtual ~bz_CustomPollOptionHandler() {};
virtual ~bz_CustomPollTypeHandler() {};

// Should return false to prevent the poll from starting
virtual bool PollOpen (bz_BasePlayerRecord *player, const char* action, const char* value) = 0;
virtual void PollClose (const char* action, const char* value, bool success) = 0;
virtual bool PollOpen (bz_BasePlayerRecord *player, const char* action, const char* parameters) = 0;
virtual void PollClose (const char* action, const char* parameters, bool success) = 0;
};

BZF_API bool bz_registerCustomPollOption (const char* option, const char* parameters, bz_CustomPollOptionHandler *handler);
BZF_API bool bz_removeCustomPollOption (const char* option);
BZF_API bool bz_registerCustomPollType (const char* option, const char* parameters, bz_CustomPollTypeHandler *handler);
BZF_API bool bz_removeCustomPollType (const char* option);

// custom commands

Expand Down
19 changes: 0 additions & 19 deletions plugins/customPollOptionSample/Makefile.am

This file was deleted.

19 changes: 19 additions & 0 deletions plugins/customPollTypeSample/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
lib_LTLIBRARIES = customPollTypeSample.la

customPollTypeSample_la_SOURCES = customPollTypeSample.cpp
customPollTypeSample_la_CPPFLAGS= -I$(top_srcdir)/include -I$(top_srcdir)/plugins/plugin_utils
customPollTypeSample_la_LDFLAGS = -module -avoid-version -shared
customPollTypeSample_la_LIBADD = $(top_builddir)/plugins/plugin_utils/libplugin_utils.la

AM_CPPFLAGS = $(CONF_CPPFLAGS)
AM_CFLAGS = $(CONF_CFLAGS)
AM_CXXFLAGS = $(CONF_CXXFLAGS)

EXTRA_DIST = \
README.customPollTypeSample.txt \
customPollTypeSample.def \
customPollTypeSample.sln \
customPollTypeSample.vcxproj

MAINTAINERCLEANFILES = \
Makefile.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
BZFlag Server Plugin: customPollOptionSample
BZFlag Server Plugin: customPollTypeSample
================================================================================

This sample plugin showing how to make use of the bz_CustomPollOptionHandler to
This sample plugin showing how to make use of the bz_CustomPollTypeHandler to
introduce custom poll options.

This plugin creates a very simple '/poll mute <callsign>' option in order to mute
Expand All @@ -13,16 +13,16 @@ Loading the plugin

This plugin takes no optional arguments, so load it with:

-loadplugin customPollOptionSample
-loadplugin customPollTypeSample


bz_CustomPollOptionHandler Functions
bz_CustomPollTypeHandler Functions
--------------------------------------------------------------------------------

There are two virtual functions that will need to be implemented by your plugin
to support custom poll options.

- bool PollOpen (int playerID, bz_ApiString action, bz_ApiString value)
- bool PollOpen (bz_BasePlayerRecord *player, const char* action, const char* parameters)

This function is called before every custom poll begins. When this function
returns true, the server will proceed and begin the poll. If the plugin
Expand All @@ -32,11 +32,11 @@ to support custom poll options.
player from this function, otherwise it will appear as if the poll failed
to start.

* playerID - the ID of the player who would like to initiate a poll
* action - the action is that being polled, e.g. 'mute'
* value - the value or target of the action, e.g. 'talkative_player'
* player - the player record of the player who would like to initiate a poll
* action - the action is that being polled, e.g. 'mute'
* value - the value or target of the action, e.g. 'talkative_player'

- void PollClose (bz_ApiString action, bz_ApiString value, bool success)
- void PollClose (const char* action, const char* parameters, bool success)

This function is called after every custom poll has ended. This is where
the business logic of a successful poll should be defined.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
// customPollOptionSample.cpp : Defines the entry point for the DLL application.
// customPollTypeSample.cpp : Defines the entry point for the DLL application.
//

#include "bzfsAPI.h"
#include "plugin_utils.h"

class customPollOptionSample : public bz_Plugin, public bz_CustomPollOptionHandler
class customPollTypeSample : public bz_Plugin, public bz_CustomPollTypeHandler
{
public:
virtual const char* Name () {return "Custom Poll Option";}
virtual const char* Name () {return "Custom Poll Type";}
virtual void Init ( const char* config );
virtual void Cleanup ( void );
virtual void Event ( bz_EventData * /* eventData */ ) {return;}

virtual bool PollOpen (bz_BasePlayerRecord *player, const char* action, const char* value);
virtual void PollClose (const char* action, const char* value, bool success);
virtual bool PollOpen (bz_BasePlayerRecord *player, const char* action, const char* parameters);
virtual void PollClose (const char* action, const char* parameters, bool success);
};

BZ_PLUGIN(customPollOptionSample)
BZ_PLUGIN(customPollTypeSample)

void customPollOptionSample::Init ( const char* /*commandLine*/ )
void customPollTypeSample::Init ( const char* /*commandLine*/ )
{
// This will introduce a '/poll mute callsign' option
bz_registerCustomPollOption("mute", "callsign", this);
bz_registerCustomPollType("mute", "callsign", this);
}

void customPollOptionSample::Cleanup ()
void customPollTypeSample::Cleanup ()
{
Flush();

// Remove the poll option when this plugin is loaded or else what other plugin would handle it?
bz_removeCustomPollOption("mute");
bz_removeCustomPollType("mute");
}

// This function is called before a `/poll mute <callsign>` poll is started. If this function returns false, then the poll will not
// start. This is useful for checking permissions or other conditions.
bool customPollOptionSample::PollOpen(bz_BasePlayerRecord *player, const char* action, const char* value)
bool customPollTypeSample::PollOpen(bz_BasePlayerRecord *player, const char* action, const char* parameters)
{
int playerID = player->playerID;
std::string _action = action;
std::string _parameters = parameters;

// If a player doesn't have the 'poll' permission, they will not be able to start a poll. Be sure to send the playerID a message
// or else it'll appear as if the /poll command did not work.
Expand All @@ -47,7 +47,7 @@ bool customPollOptionSample::PollOpen(bz_BasePlayerRecord *player, const char* a
}

// The 'action' variable will be set whichever poll option is being called
if (_action == "mute") {
if (_parameters == "mute") {

// Return true in order to let BZFS start the poll
return true;
Expand All @@ -57,16 +57,16 @@ bool customPollOptionSample::PollOpen(bz_BasePlayerRecord *player, const char* a
return false;
}

void customPollOptionSample::PollClose(const char* action, const char* value, bool success)
void customPollTypeSample::PollClose(const char* action, const char* parameters, bool success)
{
std::string _action = action;
std::string _value = value;
std::string _parameters = parameters;

if (_action == "mute" && success) {
bz_BasePlayerRecord *pr = bz_getPlayerBySlotOrCallsign(_value.c_str());
bz_BasePlayerRecord *pr = bz_getPlayerBySlotOrCallsign(_parameters.c_str());

if (!pr) {
bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "player %s not found", _value.c_str());
bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "player %s not found", _parameters.c_str());
return;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
LIBRARY customPollOptionSample
LIBRARY customPollTypeSample

EXPORTS
; Explicit exports can go here
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "customPollOptionSample", "customPollOptionSample.vcxproj", "{1F43075E-8AF6-486F-AEDF-6B350A6CE141}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "customPollTypeSample", "customPollTypeSample.vcxproj", "{1F43075E-8AF6-486F-AEDF-6B350A6CE141}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "plugin_utils", "..\plugin_utils\plugin_utils.vcxproj", "{645768BE-97C8-4DE4-9100-111BD2808B35}"
EndProject
Expand Down

0 comments on commit c15c18a

Please sign in to comment.