PDA

View Full Version : Small patch to see the long name of the zone in the web interface


erde
04-19-2009, 10:57 AM
Small patch to see the long name of the zone in the web interface, i am working currently on a server status page so i need this piece of code ;)


diff -r 1119a9fad2a9 world/EQW.cpp
--- a/world/EQW.cpp Sun Apr 19 10:41:37 2009 +0200
+++ b/world/EQW.cpp Sun Apr 19 16:39:35 2009 +0200
@@ -140,7 +140,7 @@
res["zone_id"] = itoa(zs->GetZoneID());
res["launch_name"] = zs->GetLaunchName();
res["short_name"] = zs->GetZoneName();
- res["long_name"] = zs->GetZoneName(); //TODO: get this some day
+ res["long_name"] = zs->GetZoneLongName();
res["port"] = itoa(zs->GetCPort());
res["player_count"] = itoa(zs->NumPlayers());
diff -r 1119a9fad2a9 world/zoneserver.cpp
--- a/world/zoneserver.cpp Sun Apr 19 10:41:37 2009 +0200
+++ b/world/zoneserver.cpp Sun Apr 19 16:39:35 2009 +0200
@@ -64,7 +64,8 @@
BootingUp = false;

const char* zn = MakeLowerString(database.GetZoneName(iZoneID));
-
+ char* longname;
+
if (iZoneID)
zlog(WORLD__ZONE,"Setting to '%s' (%d)%s",(zn) ? zn : "",iZoneID,iStaticZone ? " (Static)" : "");

@@ -80,9 +81,21 @@
staticzone = iStaticZone;

if (zn)
+ {
strcpy(zone_name, zn);
+ if( database.GetZoneLongName( (char*)zone_name, &longname, NULL, NULL, NULL, NULL, NULL, NULL ) )
+ {
+ strcpy(long_name, longname);
+ safe_delete( longname );
+ }
+ else
+ strcpy(long_name, "");
+ }
else
+ {
strcpy(zone_name, "");
+ strcpy(long_name, "");
+ }

client_list.ZoneBootup(this);
ls_zboot.Start();
diff -r 1119a9fad2a9 world/zoneserver.h
--- a/world/zoneserver.h Sun Apr 19 10:41:37 2009 +0200
+++ b/world/zoneserver.h Sun Apr 19 16:39:35 2009 +0200
@@ -50,6 +50,7 @@
void SendGroupIDs();

inline const char* GetZoneName() const { return zone_name; }
+ inline const char* GetZoneLongName() const { return long_name; }
const char* GetCompileTime() const{ return compiled; }
void SetCompile(char* in_compile){ strcpy(compiled,in_compile); }
inline int32 GetZoneID() const { return zoneID; }
@@ -82,6 +83,7 @@
int32 pNumPlayers;
char compiled[25];
char zone_name[16];
+ char long_name[256];
int32 zoneID;
int32 oldZoneID;
Timer ls_zboot;

erde
04-19-2009, 02:45 PM
Here is a pic how it looks now
http://www.quadfreunde-ergoldsbach.de/bilder/zones.jpg

cavedude
04-21-2009, 02:07 PM
Thanks, this will be in my next commit.

cavedude
05-03-2009, 04:18 PM
This has been committed in Revision 454.

trevius
05-05-2009, 07:00 PM
On a related note; Is there any way to have this screen display which dynamic zone process that each zone is using? As far as I can tell, the only way to currently figure out which zones are using which process is to read through the log files. It would be nice if there was a considerably easier way to do this. It would be very useful.

erde
05-06-2009, 03:36 AM
On a related note; Is there any way to have this screen display which dynamic zone process that each zone is using? As far as I can tell, the only way to currently figure out which zones are using which process is to read through the log files. It would be nice if there was a considerably easier way to do this. It would be very useful.

I cant look into the log file currently, i am at work. But do you mean the process id? To be able to attach to the process and debug?

I am not a win or linux system programmer, but i think nothing is impossible. Only takes time, i will look into these when i have some time.

trevius
05-06-2009, 06:00 AM
Basically, I mean the name of the process.

./zone dynamic_47 zone

Or whatever the process is named. Just showing the "dynamic_47" would be awesome. For servers that run many dynamic zones, it could make troubleshooting issues easier. Every time I have a problem with a dynamic crashing for any reason, it can be a pain to figure out which one it is. Had issues with it yesterday while trying to figure out the cause of some crashes, which is why I brought it up.

erde
05-06-2009, 07:38 AM
Like that?
http://quadfreunde-ergoldsbach.de/bilder/dynamic.jpg


Index: world/EQW.cpp
================================================== =================
--- world/EQW.cpp (Revision 473)
+++ world/EQW.cpp (Arbeitskopie)
@@ -139,6 +139,7 @@
res["type"] = zs->IsStaticZone()?"static":"dynamic";
res["zone_id"] = itoa(zs->GetZoneID());
res["launch_name"] = zs->GetLaunchName();
+ res["launched_name"] = zs->GetLaunchedName();
res["short_name"] = zs->GetZoneName();
res["long_name"] = zs->GetZoneLongName();
res["port"] = itoa(zs->GetCPort());


and in utils/default/template/zones.html change
around line 51

if($zone->{zone_id} == 0) {
print "\t<td><b>Dynamic:</b> <a href='zone.html?zone=$zone->{short_name}'>Idle</a></td>";
} else {
print "\t<td><b>Dynamic:</b> <a href='zone.html?zone=$zone->{short_name}'>$zone->{long_name}</a> ($zone->{short_name})</td>";
}


to


if($zone->{zone_id} == 0) {
print "\t<td><b>Dynamic:</b> <a href='zone.html?zone=$zone->{short_name}'>Idle</a><br>$zone->{launched_name}</td>";
} else {
print "\t<td><b>Dynamic:</b> <a href='zone.html?zone=$zone->{short_name}'>$zone->{long_name}</a> ($zone->{short_name})<br>$zone->{launched_name}</td>";
}

trevius
05-06-2009, 08:05 AM
Yeah, just like that! Maybe we could move the process name for dynamics to the left of the zone name instead of having it say "Dynamic". Not a big deal, but that would probably cut down the page length some instead of doing it on the next line. I run 50 dynamics, so less is more. Gonna get this tested and see how it looks. If people are ok with it, I will get it added to the SVN. Thanks, Erde!

Tested this and it seems to work well:
if($zone->{zone_id} == 0) {
print "\t<td><b>$zone->{launched_name}:</b> <a href='zone.html?zone=$zone->{short_name}'>Idle</a></td>";
} else {
print "\t<td><b>$zone->{launched_name}:</b> <a href='zone.html?zone=$zone->{short_name}'>$zone->{long_name}</a> ($zone->{short_name})</td>";
}

Anyone have a preference?

dynamic_02: Idle
dynamic_03: Idle
dynamic_01: Nexus (nexus)

That is what it looks like with the change above. Looks really good to me :)

trevius
05-07-2009, 03:52 AM
Got this commited to the SVN. Thanks again for it! I am certain this will come in handy :)