Hi,
I got bored at work today and decided to get the realmstatus to work for EU servers. The fix is dirty, but the result is a fixed realmstatus (check it out on
my site).
I had to change 2 files: realmstatus.php (duh) and enUS.php in the localizations directory (I should change fr, es and de, but hell that would leave nothing for you guys
).
So let's look at what I did in the files.
realmstatus.php
I changed the xmlmeta's to reflect as much as possible the xml scheme followed on the EU server:
- Code: Select all
$xmlmeta['rootxml'] = 'rss';
$xmlmeta['realms'] = 'channel';
$xmlmeta['name'] = 'title';
$xmlmeta['status'] = '0';
$xmlmeta['type'] = '2';
$xmlmeta['pop'] = '3';
I know these meta's are nowhere near what is in the XML, but I wanted to change the original file as little as possible.
Next I had to tackle the foreach loop that takes the data for every realm out of the xmlparsed data and puts it in the "value" variable. As the XML scheme for EU and US is so different, I took the xmlparsed data out of the foreach statement and made this conditional on the chosen realm:
- Code: Select all
if ($region == 'EU') {
$xmlpdata = $xmlParser->data[$xmlmeta['rootxml']][0]['child'][$xmlmeta['realms']][0]['child']['item'];
} else {
$xmlpdata = $xmlParser->data[$xmlmeta['rootxml']][0]['child'][$xmlmeta['realms']];
}
foreach( $xmlpdata as $key => $value )
This gives me comparable "value" variables, so I can keep the rest of the program structure. Now the key we are interested in for EU is 'child', so again, we have to go conditional. At the same time I extract the realm name because we will need it immediately after this:
- Code: Select all
if ($region == 'EU') {
$xml_server = $value['child'];
$rlmname = $xml_server[$xmlmeta['name']][0]['data'];
} else {
$xml_server = $value['attribs'];
$rlmname = $xml_server[$xmlmeta['name']];
}
if( $rlmname == $realmname )
So, now we have the realm name and all the xml_server data we need for the rest. If the server name is the one we configured, then we need the status, type and population:
- Code: Select all
if ($region == 'EU') {
$rlmstatus = $xml_server['category'][$xmlmeta['status']]['data'];
$rlmtype = $xml_server['category'][$xmlmeta['type']]['data'];
$rlmpop = $xml_server['category'][$xmlmeta['pop']]['data'];
} else {
$rlmstatus = $xml_server[$xmlmeta['status']];
$rlmtype = $xml_server[$xmlmeta['type']];
$rlmpop = $xml_server[$xmlmeta['pop']];
}
Because of this, the switch statements change as well, to switch on the rlmstatus, rlmtype and rlmpop variables. Also for status and population, the cases change too. For status nothing drastic, I just added "REALM DOWN" to the first case (not checked) and "REALM UP" to the second, but for population I had to be more creative.
On the EU realm status page, population shows either "Full", "Recommended" or "". In the XML data this translates to population being "Full" or "Recommended", but there is no XML data for ""... What happens then is that the next category (queue) becomes population data... weird.
Now there is a way to check which data you are dealing with by drilling further down in the XML scheme to "domain" to see that you are dealing with population or queue, but I am lazy by nature and I assumed that if it isn't "Full" or "Recommended" it is " " (not "" or it will fail the empty check later on).
This also means that I don't use queue data.
- Code: Select all
case 'FULL': // <-- added for EU region
$realmData['serverpop'] = 'FULL';
break;
case 'RECOMMENDED': //<-- added for EU region
$realmData['serverpop'] = 'RECOMMENDED';
break;
default:
if ($region =='EU') {
$realmData['serverpop'] = ' ';
} else {
$realmData['serverpop'] = 'ERROR';
}
So, that's it for extracting the data from the XML. Now all I had to do was make sure that you get the right color for "recommended", "full" and "" population texts:
- Code: Select all
if ($region == 'EU') {
switch ($realmData['serverpop'])
{
case 'FULL':
$realmData['serverpopcolor'] = '#990000';
break;
case 'RECOMMENDED':
$realmData['serverpopcolor'] = '#0033FF';
break;
default:
$realmData['serverpopcolor'] = $roster->config['rs_color_medium'];
break;
}
} else {
$realmData['serverpopcolor'] = $roster->config['rs_color_' . strtolower($realmData['serverpop'])];
}
I hardcoded the colors for "full" and "recommended" to the same colors used by Blizz, because I didn't want to change the rostercp thingy, because I'm lazy
enUS.phpAll that I had to do was add "RECOMMENDED" and "FULL" to the lang['rs'] array:
- Code: Select all
$lang['rs'] = array(
'ERROR' => 'Error',
'NOSTATUS' => 'No Status',
'UNKNOWN' => 'Unknown',
'RPPVP' => 'RP-PvP',
'PVE' => 'Normal',
'PVP' => 'PvP',
'RP' => 'RP',
'OFFLINE' => 'Offline',
'LOW' => 'Low',
'MEDIUM' => 'Medium',
'HIGH' => 'High',
'MAX' => 'Max',
'RECOMMENDED' => 'Recommended',
'FULL' => 'Full'
);
So, that's it. I've attached the realmstatus.php file to this post and hope you find it usefull until our dearly beloved developers come up with a nice solution to this problem.
If you are localizing in fr, de or es, please post the translations here for me and others like me (to lazy to babelfish).
Teta
I break for giant Cyber-Hamsters.