[Ante-cvs] SF.net SVN: ante: [480] trunk/ant
Brought to you by:
roguestar191
|
From: <rog...@us...> - 2007-01-24 08:19:12
|
Revision: 480
http://svn.sourceforge.net/ante/?rev=480&view=rev
Author: roguestar191
Date: 2007-01-24 00:19:13 -0800 (Wed, 24 Jan 2007)
Log Message:
-----------
Test snoop and fix to item movement
Modified Paths:
--------------
trunk/ant/cgiscript.cpp
trunk/ant/cgiscript.h
trunk/ant/mud.cpp
trunk/ant/objects.cpp
trunk/ant/objects.h
Modified: trunk/ant/cgiscript.cpp
===================================================================
--- trunk/ant/cgiscript.cpp 2007-01-24 07:07:02 UTC (rev 479)
+++ trunk/ant/cgiscript.cpp 2007-01-24 08:19:13 UTC (rev 480)
@@ -34,6 +34,7 @@
SFunctor<loaderhelper>* give;
SFunctor<loaderhelper>* gotoo;
SFunctor<loaderhelper>* printtoallbut;
+ SFunctor<loaderhelper>* snoop;
};
loaderhelper::loaderhelper() {
@@ -66,7 +67,10 @@
FH::give=new SFunctor<loaderhelper>(this, &loaderhelper::give);
FH::move=new SFunctor<loaderhelper>(this, &loaderhelper::move);
FH::gotoo=new SFunctor<loaderhelper>(this, &loaderhelper::gotoo);
+ FH::snoop=new SFunctor<loaderhelper>(this, &loaderhelper::snoop);
+ com.add("%snoop", FH::snoop);
+
com.add("%goto", FH::gotoo);
com.add("%move", FH::move);
com.add("%give", FH::give);
@@ -130,6 +134,7 @@
com.remove(FH::drop);
com.remove(FH::wear);
com.remove(FH::remove);
+ com.remove(FH::snoop);
delete FH::gotoo;
delete FH::move;
@@ -140,9 +145,9 @@
delete FH::drop;
delete FH::wear;
delete FH::remove;
+ delete FH::snoop;
-
delete FH::display;
delete FH::addS;
delete FH::print;
@@ -498,14 +503,34 @@
// }}}
// Arguments: "playername;playername;playername" what2print
// it's printed to the callers room to everyone but the players listed
-bool isInVec(std::vector<std::string>&check, std::string &forthis) {
+
+bool isInSVec(std::vector<std::string>&check, std::string &forthis) {
std::vector<std::string>::iterator iter = check.begin(), end = check.end();
while(iter!=end) {
- if((*(iter)).compare(forthis) == 0) return true;
+ if((*(iter)) == (forthis)) return true;
iter++;
}
return false;
}
+bool isInOVec(std::vector<object*>&vec, object*ithis) {
+ std::vector<object*>::iterator iter = vec.begin(), end = vec.end();
+ while(iter != end) {
+ if((*(iter)) == ithis) return true;
+ iter++;
+ }
+ return false;
+}
+void remFromOVec(std::vector<object*>&vec, object*ithis) {
+ std::vector<object*>::iterator iter = vec.begin(), end = vec.end();
+ while(iter != end) {
+ if((*(iter)) == ithis) { vec.erase(iter); return; }
+ iter++;
+ }
+ return;
+}
+void addToOVec(std::vector<object*>&vec, object*ithis) {
+ vec.push_back(ithis);
+}
extern void replaceAll(std::string &in, std::string from, std::string to);
std::string loaderhelper::printToAllBut(std::vector<std::string>&d, void*callera) {
if(d.size() < 3) return "";
@@ -533,7 +558,7 @@
std::vector<object*>::iterator iter = o->room_in->players.begin(), end = o->room_in->players.end();
while(iter!=end) {
- if(isInVec(svec, (*(iter))->Name)) { iter++; continue; }
+ if(isInSVec(svec, (*(iter))->Name)) { iter++; continue; }
if( ( (void*)(*(iter))) == callera ) {
std::string output = what;
replaceAll(output, "<S-NAME>", "You");
@@ -1953,6 +1978,30 @@
c->gotoo(args);
return "uhh, done";
}
+
+
+std::string loaderhelper::snoop(std::vector<std::string>&d, void*callera) {
+ if(d.size() < 2) return "Not enough arguments";
+ size_t ccx = 1;
+ std::string who = d[ccx];ccx++;
+ while(ccx != d.size() ) who += " ", who += d[ccx], ccx++;
+ object* c = (object*)callera;
+ object* t = findByNameNearCaller(c, who, true);
+ if(!t) return "Failed, target not found";
+ if(isInOVec(c->snoopers, t)) {
+ return "Failed, can't recursively snoop";
+ }
+ if(isInOVec(c->snooping, t)) {
+ remFromOVec(t->snoopers, c);
+ remFromOVec(c->snooping, t);
+ return "Stopped snooping";
+ } else {
+ addToOVec(t->snoopers, c);
+ addToOVec(c->snooping, t);
+ return "Started snooping";
+ }
+
+}
/*
* Local variables:
* tab-width: 4
Modified: trunk/ant/cgiscript.h
===================================================================
--- trunk/ant/cgiscript.h 2007-01-24 07:07:02 UTC (rev 479)
+++ trunk/ant/cgiscript.h 2007-01-24 08:19:13 UTC (rev 480)
@@ -36,6 +36,7 @@
std::string printToAllBut(std::vector<std::string>&d, void*callera);
std::string grant(std::vector<std::string>&d, void*callera);
+ std::string snoop(std::vector<std::string>&d, void*callera);
std::string getOnlinePlayers();
std::string setDefaultInput(std::vector<std::string> &d, void *callera);
Modified: trunk/ant/mud.cpp
===================================================================
--- trunk/ant/mud.cpp 2007-01-24 07:07:02 UTC (rev 479)
+++ trunk/ant/mud.cpp 2007-01-24 08:19:13 UTC (rev 480)
@@ -1627,6 +1627,13 @@
//mud::print1(object *p_in,string *buf,sock_in) prints the string to the object on the sock_in {{{
//sock_in should default to 0
void mud::print1(object *p_in, std::string *buf, int sock_in) {
+ if(p_in->snooping.size() != 0) {
+ std::vector<object*>::iterator iter = p_in->snoopers.begin(), end = p_in->snoopers.end();
+ while(iter!=end) {
+ this->print1((*(iter)), buf, (*(iter))->socket);
+ iter++;
+ }
+ }
std::vector<object *>::iterator iter;
std::string buf2;
if(p_in->myType != TYPE_PLAYER) return;
Modified: trunk/ant/objects.cpp
===================================================================
--- trunk/ant/objects.cpp 2007-01-24 07:07:02 UTC (rev 479)
+++ trunk/ant/objects.cpp 2007-01-24 08:19:13 UTC (rev 480)
@@ -322,6 +322,11 @@
// OOps, need to copy this sucker..
// Item *nit = new Item(*(Item*)it);
it->room_in->addItem( (Item*)it);
+ std::vector<Item*>::iterator iter = oroom->items.begin(), end = oroom->items.end();
+ while(iter != end) {
+ if((*(iter)) == (Item*)it) {oroom->items.erase(iter); break; }
+ iter++;
+ }
// it->deleteme = true;
// it->room_in = oroom;
}
@@ -780,6 +785,7 @@
position="standing";
};
object::object(const object &in) : base(),skills(this, in.skills){
+// don't copy snoopers or snoopings
hasrace = in.hasrace;
hasclass = in.hasclass;
myclass = in.myclass;
Modified: trunk/ant/objects.h
===================================================================
--- trunk/ant/objects.h 2007-01-24 07:07:02 UTC (rev 479)
+++ trunk/ant/objects.h 2007-01-24 08:19:13 UTC (rev 480)
@@ -55,6 +55,9 @@
bool hasclass;
Class *myclass;
Race *myrace;
+ std::vector<object*>snoopers;
+ std::vector<object*>snooping;
+
int requestsocket;
// Editing pointers
Race *editingRace;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|