From: <ma...@us...> - 2012-04-07 11:59:49
|
Revision: 8181 http://planeshift.svn.sourceforge.net/planeshift/?rev=8181&view=rev Author: magodra Date: 2012-04-07 11:59:42 +0000 (Sat, 07 Apr 2012) Log Message: ----------- - Fixed online creation of location regions. - Updated /location show to include display of region segments. - Added new /location list to show location types. Modified Paths: -------------- trunk/data/effects/misc/admin_location.eff trunk/data/effects/misc/admin_path_segment.eff trunk/data/help.xml trunk/src/common/util/location.cpp trunk/src/common/util/location.h trunk/src/server/adminmanager.cpp Modified: trunk/data/effects/misc/admin_location.eff =================================================================== --- trunk/data/effects/misc/admin_location.eff 2012-04-07 09:50:23 UTC (rev 8180) +++ trunk/data/effects/misc/admin_location.eff 2012-04-07 11:59:42 UTC (rev 8181) @@ -23,20 +23,25 @@ </mixmode> </obj> <obj type="spire" shape="cylinder" name="spark" material="myknife" segments="20"> - <attach>pos</attach> - <dir>none</dir> - <death>none</death> - <keyFrame time="0"> - <action name="position" x="0" y="0.01" z="0" /> - <action name="rotate" x="0" y="0" z="0" /> - <action name="scale" value="1" /> - <action name="height" value="0.5" /> - <action name="topscale" value="1" use_scale="1" /> - <action name="colour" r="10" g="200" b="10" /> - </keyFrame> - <keyFrame time="1000"> - <action name="topscale" value="1.0" use_scale="1" /> - </keyFrame> + <attach>pos</attach> + <dir>none</dir> + <death>none</death> + <keyFrame time="0"> + <action name="position" x="0" y="0.00" z="1" use_scale="2" /> + <action name="rotate" x="0" y="-57.295779513082320876798154814105" z="0" use_scale="3" /> + <action name="scale" value="1" /> + <action name="height" value="0.5" /> + <action name="topscale" value="1.0" use_scale="1" /> + <action name="colour" r="10" g="200" b="10" /> + </keyFrame> + <keyFrame time="5000"> + <action name="position" x="0" y="0.00" z="0" /> + <action name="rotate" x="0" y="-57.295779513082320876798154814105" z="0" use_scale="3" /> + <action name="scale" value="1" /> + <action name="height" value="0.5" /> + <action name="topscale" value="1.0" use_scale="1" /> + <action name="colour" r="10" g="200" b="10" /> + </keyFrame> </obj> </effect> </addon> Modified: trunk/data/effects/misc/admin_path_segment.eff =================================================================== --- trunk/data/effects/misc/admin_path_segment.eff 2012-04-07 09:50:23 UTC (rev 8180) +++ trunk/data/effects/misc/admin_path_segment.eff 2012-04-07 11:59:42 UTC (rev 8181) @@ -16,17 +16,12 @@ <anchor type="basic" name="pos"> <dir>none</dir> </anchor> - <!--obj type="mesh" name="weapons#wand01a" fact="weapons#wand01a"> - <attach>pos</attach> - <death>none</death> - <mixmode><add /></mixmode> - </obj--> <obj type="spire" shape="cylinder" name="spark" material="myknife" segments="4"> <attach>pos</attach> <dir>none</dir> <death>none</death> <keyFrame time="0"> - <action name="position" x="0" y="0.00" z="1" use_scale="2" /> + <action name="position" x="0" y="0.00" z="1" use_scale="2" /> <action name="rotate" x="0" y="-57.295779513082320876798154814105" z="0" use_scale="1" /> <action name="scale" value="1" /> <action name="height" value="0.5" /> Modified: trunk/data/help.xml =================================================================== --- trunk/data/help.xml 2012-04-07 09:50:23 UTC (rev 8180) +++ trunk/data/help.xml 2012-04-07 11:59:42 UTC (rev 8181) @@ -1299,6 +1299,8 @@ /location display /location hide /location info +/location insert +/location list /location radius /location show </content> @@ -1307,7 +1309,7 @@ <Contents> <content type="text">/location add <type> <name> <radius> [<rotation angle>] -Add a new location.</content> +Add a new location. For a list of types use the /location list command.</content> </Contents> </topic> <topic name="/location adjust"> @@ -1345,9 +1347,16 @@ Insert a new point after current selected point region.</content> </Contents> </topic> + <topic name="/location list"> + <Contents> + <content type="text">/location list + +List all location types.</content> + </Contents> + </topic> <topic name="/location radius"> <Contents> - <content type="text">/location <radius> <search radius> + <content type="text">/location radius <radius> <search radius> Adjust the radius of the location nearest current position.</content> </Contents> Modified: trunk/src/common/util/location.cpp =================================================================== --- trunk/src/common/util/location.cpp 2012-04-07 09:50:23 UTC (rev 8180) +++ trunk/src/common/util/location.cpp 2012-04-07 11:59:42 UTC (rev 8181) @@ -60,7 +60,12 @@ while (locs.GetSize()) { Location * loc = locs.Pop(); - delete loc; + // First location in a region is the location that holds the locs array. + // The first location is in the locs as well so don't delete self yet. + if (loc != this) + { + delete loc; + } } } @@ -172,8 +177,15 @@ Location* Location::Insert(iDataConnection* db, csVector3 &pos, iSector* sector) { Location* location = new Location(type, name, pos, sector, radius, rot_angle, GetFlags()); - location->id_prev_loc_in_region = id; + location->id_prev_loc_in_region = GetID(); + // Check if this location is in a region, if not convert this locaiton into a region. + if (!region) + { + locs.Push( this ); // First location is in the locs as well. + region = this; + } + // Create DB entry location->CreateUpdate(db); @@ -184,8 +196,15 @@ next->id_prev_loc_in_region = location->GetID(); next->CreateUpdate(db); - region->locs.Insert((index+1)%region->locs.GetSize(),location); - + if (index+1 >= region->locs.GetSize()) + { + region->locs.Push(location); + } + else + { + region->locs.Insert((index+1)%region->locs.GetSize(),location); + } + return location; } @@ -195,13 +214,27 @@ location->SetID(id); location->id_prev_loc_in_region = GetID(); + // Check if this location is in a region, if not convert this locaiton into a region. + if (!region) + { + locs.Push( this ); // First location is in the locs as well. + region = this; + } + // Update all the pointers and stuff. location->region = region; size_t index = region->locs.Find(this); Location* next = region->locs[(index+1)%region->locs.GetSize()]; next->id_prev_loc_in_region = location->GetID(); - region->locs.Insert((index+1)%region->locs.GetSize(),location); + if (index+1 >= region->locs.GetSize()) + { + region->locs.Push(location); + } + else + { + region->locs.Insert((index+1)%region->locs.GetSize(),location); + } return location; } @@ -257,7 +290,7 @@ values.FormatPush("%.2f",rot_angle); values.FormatPush("%.2f",radius); csString flagStr; - values.Push(flagStr); + values.Push(flagStr.GetDataSafe()); values.FormatPush("%d",GetSectorID(db,sectorName)); if (id == -1) @@ -724,6 +757,20 @@ return location; } + if (location->IsRegion()) + { + for (size_t j=0; j<location->locs.GetSize(); j++) + { + Location* location2 = location->locs[j]; + + if (location2->GetID() == id) + { + return location2; + } + } + } + + } return NULL; } @@ -834,9 +881,9 @@ return loctypes.GetIterator(); } -Location* LocationManager::CreateLocation(iDataConnection* db, const char* locationTypeName, const char* locationName, csVector3& pos, iSector* sector, float radius, float rot_angle, const csString& flags) +Location* LocationManager::CreateLocation(iDataConnection* db, LocationType* locationType, const char* locationName, csVector3& pos, iSector* sector, float radius, float rot_angle, const csString& flags) { - Location* location = CreateLocation(locationTypeName, locationName, pos, sector, radius, rot_angle, flags); + Location* location = CreateLocation(locationType, locationName, pos, sector, radius, rot_angle, flags); if (!location->CreateUpdate(db)) { Modified: trunk/src/common/util/location.h =================================================================== --- trunk/src/common/util/location.h 2012-04-07 09:50:23 UTC (rev 8180) +++ trunk/src/common/util/location.h 2012-04-07 11:59:42 UTC (rev 8181) @@ -49,7 +49,7 @@ csVector3 pos; ///< The positon of this location float rot_angle; ///< Some location has an angle. float radius; ///< The radius of this locaiton. - csArray<Location*> locs; ///< A number of points for regions. + csArray<Location*> locs; ///< A number of points for regions. Including self for first location in region. int id_prev_loc_in_region; ///< Prev database ID for a region. csString sectorName; ///< The sector where this location is located. @@ -341,7 +341,7 @@ /** Create a new location. And add it to the DB. */ - Location* CreateLocation(iDataConnection* db, const char* locationTypeName, const char* locationName, csVector3& pos, iSector* sector, float radius, float rot_angle, const csString& flags); + Location* CreateLocation(iDataConnection* db, LocationType* locationType, const char* locationName, csVector3& pos, iSector* sector, float radius, float rot_angle, const csString& flags); /** Create a new location */ Modified: trunk/src/server/adminmanager.cpp =================================================================== --- trunk/src/server/adminmanager.cpp 2012-04-07 09:50:23 UTC (rev 8180) +++ trunk/src/server/adminmanager.cpp 2012-04-07 11:59:42 UTC (rev 8181) @@ -3135,6 +3135,7 @@ subCommandList.Push("hide",""); subCommandList.Push("info",""); subCommandList.Push("insert",""); + subCommandList.Push("list",""); subCommandList.Push("radius","<radius> [<search radius>]"); subCommandList.Push("select","[<search radius>]"); @@ -7122,8 +7123,15 @@ for (int i = 0; i < location->locs.GetSize(); i++) { Location* loc = location->locs[i]; + Location* next = location->locs[(i+1)%location->locs.GetSize()]; + + csVector3 delta = next->GetPosition() - loc->GetPosition(); + + float angle = atan2(delta.x,delta.z); + float length = delta.Norm(); + psEffectMessage msg(client->GetClientNum(),"admin_location", - loc->GetPosition(),0,0,loc->GetEffectID(this),loc->GetRadius()); + next->GetPosition(),0,0,next->GetEffectID(this),0.1f,length,angle); msg.SendMessage(); } } @@ -7230,7 +7238,14 @@ if (data->subCommand == "add") { - Location* location = locations->CreateLocation(db, data->locationType, data->locationName, myPos, mySector, data->radius, data->rotAngle, ""); + LocationType* locationType = locations->FindLocation(data->locationType); + if (!locationType) + { + psserver->SendSystemInfo(me->clientnum, "Failed to find locations type %s.",data->locationType.GetDataSafe()); + return; + } + + Location* location = locations->CreateLocation(db, locationType, data->locationName, myPos, mySector, data->radius, data->rotAngle, ""); if (location) { @@ -7330,11 +7345,27 @@ { psserver->npcmanager->LocationInserted(location); + // Update the selected location to the new created location + client->SetSelectedLocationID(location->GetID()); // Use ID to prevent pointer problems. + UpdateDisplayLocation(location); psserver->SendSystemInfo(me->clientnum,"Inserted new location %s(%d)",location->GetName(),location->GetID()); } } + else if (data->subCommand == "list") + { + csString types; + types += "Locations:\n"; + csHash<LocationType*, csString>::GlobalIterator iter(locations->GetIterator()); + while (iter.HasNext()) + { + LocationType* type = iter.Next(); + types.AppendFmt(" %s\n",type->GetName()); + } + + psserver->SendSystemInfo(me->clientnum,types); + } else if (data->subCommand == "radius") { float distance=0.0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |