Thread Tools Display Modes
01-27-14, 11:28 AM   #1
jaliborc
A Chromatic Dragonspawn
 
jaliborc's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2007
Posts: 196
Detect Current Region

I've been looking for ways of an addon to detect wether it is on the US, European or Chinese regions. One method I found was using the cvar "portal":

Code:
local region = GetCVar('portal')
if region == 'eu' then
-- do european stuff
end
Does anyone knows if this is a reliable solution or if there is some alternative?
  Reply With Quote
01-27-14, 11:43 AM   #2
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
GetCVar("installLocale") isnt better?

But it's flaw its returns enUS for enGB clients too.

Actually i have no portal named cvar so i'm not sure what it that.

Last edited by Resike : 01-27-14 at 11:46 AM.
  Reply With Quote
01-27-14, 01:04 PM   #3
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,359
I've been using
Code:
local realmlist = GetCVar("realmList")
local region = string.match(realmlist,"(%a+)%..+")
if region then
  -- use region
end
in my addons for years, had no complaints from users so I'd guess it works

Edit: Install locale is irrelevant, you can be playing in the eu region and have a deDE or frFR locale client.

Last edited by Dridzt : 01-27-14 at 01:07 PM.
  Reply With Quote
01-27-14, 01:14 PM   #4
jaliborc
A Chromatic Dragonspawn
 
jaliborc's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2007
Posts: 196
Originally Posted by Resike View Post
GetCVar("installLocale") isnt better?

But it's flaw its returns enUS for enGB clients too.

Actually i have no portal named cvar so i'm not sure what it that.
Like you mentioned, it is not guaranteed to distinguish same locales on different regions, so it's not a solution. But thanks for the tip!

Originally Posted by Dridzt View Post
I've been using
Code:
local realmlist = GetCVar("realmList")
local region, rest = string.match(realmlist,"(%a+)%.(.+)")
if region then
  -- use region
end
in my addons for years, had no complaints from users so I'd guess it works
If you have been using it, then it's good enough for me!
  Reply With Quote
01-28-14, 07:52 AM   #5
Vlad
A Molten Giant
 
Vlad's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 793
Blizzard define your realmList to a domain where your login server is located.

Luckily they prefix it, but they CAN use an IP directly breaking the code. It might also be different for Chinese servers.

For example http://wowchina.com/ don't even use the prefix like the us/eu does, so keep this in mind. The Chinese realmlist is cn#.grunt.wowchina.com
__________________
Profile: Curse | Wowhead
  Reply With Quote
01-29-14, 12:24 PM   #6
Nimhfree
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 267
I would guess the API to use would depend on what you need it for. I too use the portal value in Grail:

self.portal = GetCVar("portal")

because specific quests are not available to the European servers. Since this covers Europe and not a specific language the portal value seems to be the right way to go.

However, I have not checked on whether this is still set since I originally put in in place many moons ago.
  Reply With Quote
01-29-14, 05:06 PM   #7
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
But for any EU realm, the EU realm list will be used, no? Am I missing the point?
__________________
Grab your sword and fight the Horde!
  Reply With Quote
01-30-14, 06:53 AM   #8
jaliborc
A Chromatic Dragonspawn
 
jaliborc's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2007
Posts: 196
Originally Posted by Vlad View Post
Blizzard define your realmList to a domain where your login server is located.

Luckily they prefix it, but they CAN use an IP directly breaking the code. It might also be different for Chinese servers.

For example http://wowchina.com/ don't even use the prefix like the us/eu does, so keep this in mind. The Chinese realmlist is cn#.grunt.wowchina.com
Thanks or the heads up.

Originally Posted by Lombra View Post
But for any EU realm, the EU realm list will be used, no? Am I missing the point?
Basically, it will work as long as we don't assume realmlists start all with the same format. One might simply check the entire realmlist string, for example.
  Reply With Quote
01-31-14, 01:19 PM   #9
Rainrider
A Firelord
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 454
Is it possible to get the server locale? Like deDE or something if it is a german server.

Btw: GetCVar("installLocale") is the same as GetLocale(). If you need to diffentiate between enUS/enGB then use GetCVar("locale") instead. Those are just the language preference of the client though.

Last edited by Rainrider : 01-31-14 at 01:24 PM.
  Reply With Quote
02-01-14, 05:54 AM   #10
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by Rainrider View Post
Is it possible to get the server locale? Like deDE or something if it is a german server.

Btw: GetCVar("installLocale") is the same as GetLocale(). If you need to diffentiate between enUS/enGB then use GetCVar("locale") instead. Those are just the language preference of the client though.
Nope, the insallLocale is the language of your game's disc, but since they were shipping enUS disc to enGB too its enUS for users in Europe too. At least is should be different for chinese and korean users.

The GetCVar("locale") could work that was my second tought.
  Reply With Quote
02-01-14, 06:45 AM   #11
jaliborc
A Chromatic Dragonspawn
 
jaliborc's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2007
Posts: 196
I think realmlist is really the way to go, and has been working son far for me. I'm want to detect connected servers, so I don't care about languages. If one really wants to know if a server is enUS or enGB, or if it is esES or esMX, I guess the solution is to use the realmlist and GetLocale in conjunction.
  Reply With Quote
02-01-14, 07:11 AM   #12
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by jaliborc View Post
If one really wants to know if a server is enUS or enGB, or if it is esES or esMX, I guess the solution is to use the realmlist and GetLocale in conjunction.
GetLocale actually returns "esES" or "esMX" as appropriate, as those are separate localizations with a few differences in their translations (eg. a different word for "dungeon" is used).

However, it does return "enUS" in an enGB client, and "ptBR" in a ptPT client, as there are not actually separate localizations for the EU variants of English and Portuguese; they just use the enUS and ptBR translations, so in those cases you would need to use the realmlist if you need to distinguish between them.

Originally Posted by Resike View Post
Nope, the insallLocale is the language of your game's disc, but since they were shipping enUS disc to enGB too its enUS for users in Europe too. At least is should be different for chinese and korean users.
The installLocale is whatever language the user chose when they first downloaded the installer, which can be any language the game is playable in. If anyone is actually still buying physical discs, I know the expansions are available in languages other than English; I'd assume the base game or "battle chest" or whatever they're calling it now is too.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
02-01-14, 09:14 AM   #13
Rainrider
A Firelord
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 454
I bought my German physical discs in Germany. I chose enGB (you can't choose enUS in europe) and I play on a German server. "installLocale" is still enUS for me for whatever reason. It is common to meet people playing in English. It is not uncommon to even see Russian. I can even take Italian and am still able to login to my German server. I think automated responses like those about boss encounter progress are better delivered in the server language as I can expect that the large majority of players on a German server can understand German. I can't expect them to know Italian. That would be my reason to look for the exact server locale and not just the region.
  Reply With Quote
02-01-14, 01:41 PM   #14
jaliborc
A Chromatic Dragonspawn
 
jaliborc's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2007
Posts: 196
Well, the server language is really just a human protocol. See for instance Aggra EU, it's even in the english category but it's a portuguese server.
Anyway, given the region you can have a table mapping every realm to it's language. You only need to check the region because names in EU and US servers are shared.
  Reply With Quote
06-06-14, 02:24 PM   #15
Simca
An Aku'mai Servant
 
Simca's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2012
Posts: 33
A heads-up to users of GetCVar("realmList") - you will need another solution for WoD. That CVar is managed by the BNet app and is deprecated. Fresh installs will no longer have it set.

GetCVar("portal") does seem to still work. It returns "public-test" on PTRs/beta realms though, so make sure to account for that (I would test the returned value and call test realms 'xx' personally, since that's what realmList did).

This change breaks many addons, including part of Ace3.
__________________
Assistant admin for MMO-Champion
WoW database file expert - ask me anything
  Reply With Quote
07-19-14, 02:12 PM   #16
Kaelten
Jack's raging bile duct
 
Kaelten's Avatar
Featured
Join Date: May 2005
Posts: 782
I've got a new alpha build out of Ace3 that addresses this cvar change.

Let me know if there's any issues with it.
__________________
WowAce.com & CurseForge.com Adminstrator
Developer of Ace3, OneBag3, and many other addons and libraries
Project lead and Mac developer for the Curse Client

Anyone that needs what they want
And doesn't want what they need
I want nothing to do with
  Reply With Quote
07-22-14, 07:07 PM   #17
Bringer
A Fallenroot Satyr
 
Bringer's Avatar
Join Date: Jul 2012
Posts: 26
Portal appears to be incomplete solution

One of my testers has a Battlenet account with WoW accounts in both US and EU regions.
The tester confirmed the following query of her exact setup and results.

Just to make sure I fully understand.. from your home in the UK
You have one Battlenet accountID
in that account you have two EU-Wow accounts. a US-Wow account starter account, and a WoD beta account
You have a single copy of WoW installed for the live accounts and a copy for the WoD beta account.

You launch with battlenet desktop app
you login using your battlenet accountID

At the battlenet games starter screen...
with Wow selected you select your desired WoW account and press the PLAY button launching the WoW client.

On launch you are logged into the WoW client and are at the character selection screen of the realm you last played.
Assuming you want to play on a different realm you press the CHANGE REALM button and get the realm list for the region associated with your selected WoW account


Once in game on a character selected running our addon or running the script
/script local rk = GetCVar("portal") == "public-test" and "PTR" or GetCVar("portal"); print(rk)

You get the expected output of EU while in the EU region, but you still get the output of EU when in the US region?
While looking at WoD beta the script prints PTR

Changing the Battlenet region before logging on to Battlenet has no impact on the results.
  Reply With Quote
07-22-14, 09:48 PM   #18
Kaelten
Jack's raging bile duct
 
Kaelten's Avatar
Featured
Join Date: May 2005
Posts: 782
It sounds like that CVAR may get set once on first install? or perhaps it's based on geographics rather than the other?

If we could get someone who's never had WoW installed on an EU computer go and sign into the US first that'd help us know more.
__________________
WowAce.com & CurseForge.com Adminstrator
Developer of Ace3, OneBag3, and many other addons and libraries
Project lead and Mac developer for the Curse Client

Anyone that needs what they want
And doesn't want what they need
I want nothing to do with
  Reply With Quote
07-23-14, 04:43 AM   #19
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
I can only confirm that my portal is set to EU when I log my US trial, normally playing on EU accounts.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
07-23-14, 06:37 AM   #20
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Kaelten View Post
It sounds like that CVAR may get set once on first install? or perhaps it's based on geographics rather than the other?

If we could get someone who's never had WoW installed on an EU computer go and sign into the US first that'd help us know more.
Not sure how useful this is, as I don't fit that exact scenario, but I'm located in the US, with a US client, and when I'm logged into into my EU WoW account -- regardless of whether I logged in through the Battle.net launcher or directly through Wow.exe -- my tickets still go to the US support team, in spite of this:

/dump GetCVar("portal") -> "EU"
/dump GetCVar("realmList") -> "eu.logon.worldofwarcraft.com"

When logging in directly through Wow.exe it seems to automatically pick US or EU depending on the value of theinstallLocale CVar in Config.wtf -- eg. "deDE" logs into EU servers, or "enUS" to log into US servers. A setting of "enGB" still logs into US servers. The value of the locale CVar doesn't seem to make any difference.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Detect Current Region

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off