summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2004-04-05 01:03:26 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2004-04-05 01:03:26 +0000
commit1e1e59d32934ee61562804cd86321ffe849c1ecb (patch)
treedbb153dbf5c827f1a43bd2d2f306c268a8bec9ed /src
parentc5ad0a19cbf86510fc0b75ac96ea9d57598da91f (diff)
Modified the Module::OnExtendedMode() method to use a void* as its target which the coder must cast into a chanrec or userrec.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@383 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/InspIRCd.layout44
-rw-r--r--src/inspircd.cpp4
-rw-r--r--src/modules.cpp2
-rw-r--r--src/modules/m_cloaking.cpp19
-rw-r--r--src/modules/m_testcommand.cpp6
5 files changed, 42 insertions, 33 deletions
diff --git a/src/InspIRCd.layout b/src/InspIRCd.layout
index 55dc76618..11aa9223f 100644
--- a/src/InspIRCd.layout
+++ b/src/InspIRCd.layout
@@ -1,5 +1,5 @@
[Editors]
-Focused=-1
+Focused=1
Order=7,3,2,6,25,24,1,4,5,0,-1
[Editor_0]
@@ -12,10 +12,10 @@ LeftChar=1
[Editor_1]
Open=1
-Top=0
-CursorCol=22
-CursorRow=384
-TopLine=372
+Top=1
+CursorCol=60
+CursorRow=2398
+TopLine=2372
LeftChar=1
[Editor_2]
@@ -37,9 +37,9 @@ LeftChar=1
[Editor_4]
Open=1
Top=0
-CursorCol=2
-CursorRow=312
-TopLine=258
+CursorCol=56
+CursorRow=118
+TopLine=91
LeftChar=1
[Editor_5]
@@ -75,7 +75,7 @@ TopLine=1
LeftChar=1
[Editor_9]
-Open=0
+Open=1
Top=0
CursorCol=1
CursorRow=1
@@ -85,9 +85,9 @@ LeftChar=1
[Editor_10]
Open=1
Top=0
-CursorCol=3
-CursorRow=146
-TopLine=91
+CursorCol=31
+CursorRow=75
+TopLine=49
LeftChar=1
[Editor_11]
@@ -163,19 +163,19 @@ TopLine=1
LeftChar=1
[Editor_20]
-Open=0
+Open=1
Top=0
-CursorCol=89
-CursorRow=297
-TopLine=1
+CursorCol=58
+CursorRow=171
+TopLine=148
LeftChar=1
[Editor_21]
-Open=0
+Open=1
Top=0
CursorCol=1
CursorRow=25
-TopLine=10
+TopLine=7
LeftChar=1
[Editor_22]
@@ -210,8 +210,8 @@ TopLine=1
LeftChar=1
[Editor_26]
Open=1
-Top=1
-CursorCol=1
-CursorRow=95
-TopLine=41
+Top=0
+CursorCol=24
+CursorRow=58
+TopLine=29
LeftChar=1
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 72b965741..adde759bf 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -2395,7 +2395,7 @@ bool allowed_umode(char umode, char* sourcemodes,bool adding)
return false;
}
-bool process_module_umode(char umode, userrec* source, userrec* dest, bool adding)
+bool process_module_umode(char umode, userrec* source, void* dest, bool adding)
{
string_list p;
p.clear();
@@ -2403,7 +2403,7 @@ bool process_module_umode(char umode, userrec* source, userrec* dest, bool addin
{
for (int i = 0; i <= MODCOUNT; i++)
{
- if (modules[i]->OnExtendedMode(source,(chanrec*)NULL,umode,MT_CLIENT,adding,p))
+ if (modules[i]->OnExtendedMode(source,(void*)dest,umode,MT_CLIENT,adding,p))
{
log(DEBUG,"Module claims umode %c",umode);
return true;
diff --git a/src/modules.cpp b/src/modules.cpp
index 59834eefc..8ff5874af 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -115,7 +115,7 @@ void Module::OnPacketReceive(char *p) { }
void Module::OnRehash() { }
void Module::OnServerRaw(std::string &raw, bool inbound) { }
int Module::OnUserPreJoin(userrec* user, chanrec* chan, char* cname) { return 0; }
-bool Module::OnExtendedMode(userrec* user, chanrec* chan, char modechar, int type, bool mode_on, string_list &params) { }
+bool Module::OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list &params) { }
Version Module::GetVersion() { return Version(1,0,0,0); }
// server is a wrapper class that provides methods to all of the C-style
diff --git a/src/modules/m_cloaking.cpp b/src/modules/m_cloaking.cpp
index aae182036..8fd4e43e5 100644
--- a/src/modules/m_cloaking.cpp
+++ b/src/modules/m_cloaking.cpp
@@ -59,7 +59,7 @@ class ModuleCloaking : public Module
return Version(1,0,0,1);
}
- virtual bool OnExtendedMode(userrec* user, chanrec* chan, char modechar, int type, bool mode_on, string_list &params)
+ virtual bool OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list &params)
{
// this method is called for any extended mode character.
// all module modes for all modules pass through here
@@ -69,6 +69,11 @@ class ModuleCloaking : public Module
// modules to 'spy' on extended mode activity if they so wish.
if ((modechar == 'x') && (type == MT_CLIENT))
{
+ // OnExtendedMode gives us a void* as the target, we must cast
+ // it into a userrec* or a chanrec* depending on the value of
+ // the 'type' parameter (MT_CLIENT or MT_CHANNEL)
+ userrec* dest = (userrec*)target;
+
// we've now determined that this is our mode character...
// is the user adding the mode to their list or removing it?
if (mode_on)
@@ -80,28 +85,28 @@ class ModuleCloaking : public Module
// will not work if the user has only one level of domain
// naming in their hostname (e.g. if they are on a lan or
// are connecting via localhost) -- this doesnt matter much.
- if (strstr(user->host,"."))
+ if (strstr(dest->host,"."))
{
// in inspircd users have two hostnames. A displayed
// hostname which can be modified by modules (e.g.
// to create vhosts, implement chghost, etc) and a
// 'real' hostname which you shouldnt write to.
- std::string a = strstr(user->host,".");
+ std::string a = strstr(dest->host,".");
char ra[64];
long seed,s2;
- memcpy(&seed,user->host,sizeof(long));
+ memcpy(&seed,dest->host,sizeof(long));
memcpy(&s2,a.c_str(),sizeof(long));
- sprintf(ra,"%.8X",seed*s2*strlen(user->host));
+ sprintf(ra,"%.8X",seed*s2*strlen(dest->host));
std::string b = Srv->GetNetworkName() + "-" + ra + a;
Srv->Log(DEBUG,"cloak: allocated "+b);
- strcpy(user->dhost,b.c_str());
+ strcpy(dest->dhost,b.c_str());
}
}
else
{
// user is removing the mode, so just restore their real host
// and make it match the displayed one.
- strcpy(user->dhost,user->host);
+ strcpy(dest->dhost,dest->host);
}
// this mode IS ours, and we have handled it. If we chose not to handle it,
// for example the user cannot cloak as they have a vhost or such, then
diff --git a/src/modules/m_testcommand.cpp b/src/modules/m_testcommand.cpp
index 307f11ad6..b464a2737 100644
--- a/src/modules/m_testcommand.cpp
+++ b/src/modules/m_testcommand.cpp
@@ -46,20 +46,24 @@ class ModuleTestCommand : public Module
Srv->AddExtendedMode('Z',MT_CHANNEL,false,1,0);
}
- virtual bool OnExtendedMode(userrec* user, chanrec* chan, char modechar, int type, bool mode_on, string_list &params)
+ virtual bool OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list &params)
{
+
if ((modechar != 'Z') || (type != MT_CHANNEL)) {
// this mode isn't ours, we have to bail and return 0 to not handle it.
Srv->Log(DEBUG,"Extended mode event triggered, but this is not a mode i've claimed!");
return 0;
}
+ chanrec* chan = (chanrec*)target;
if (mode_on) {
Srv->Log(DEBUG,"Custom mode is being added to channel");
+ Srv->Log(DEBUG,chan->name);
}
else {
Srv->Log(DEBUG,"Custom mode is being taken from a channel");
+ Srv->Log(DEBUG,chan->name);
}
// must return 1 to handle the mode!