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,360
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
07-22-14, 07:07 PM   #8
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   #9
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   #10
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   #11
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
07-23-14, 07:26 AM   #12
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
Same as Lombra

Standard Edition account on EU
Starter Edition account on US, logged on to the starter edition account
Code:
GetCVar("portal") => "EU"
GetCVar("realmList") => "eu.logon.worldofwarcraft.com"
* I did not sign in to the US account first ><
  Reply With Quote
07-23-14, 02:36 PM   #13
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
I'm in EU

Fresh (Win8+WoW) install and logged into US starter edition account first
Code:
GetCVar("portal") => "US"
GetCVar("realmList") => "us.logon.worldofwarcraft.com"

Afterwards logged in to EU account, it's still the same
Code:
GetCVar("portal") => "US"
GetCVar("realmList") => "us.logon.worldofwarcraft.com"

Are we talking about the CVars on Live servers or the WoD beta servers? I'm a bit confused now

Last edited by Ketho : 07-23-14 at 02:45 PM.
  Reply With Quote
07-23-14, 04:10 PM   #14
Bringer
A Fallenroot Satyr
 
Bringer's Avatar
Join Date: Jul 2012
Posts: 26
info? From Blizzard support

https://us.battle.net/support/en/art...he-game-region

I have 2 different WoW client installs each attached to a different Battlenet ID, my original US and a testing starter EU (Battlenet app installed with newer EU client)
both have SET installLocale "enUS"
both have SET locale US has "enUS" EU has "enGB"
neither have SET portal

All testing on original US client when using Battlenet account.. allowing app to shutdown on game start.
test 1 on US client
edit WTF/Config.wtf add SET portal "EU" change SET local "enGB"
launch wow-64.exe login using my EU test ID
get EU's read TerminationWithoutNotice
after back and forth finally get realm.. and EU realm list. login character.. exit client
WTF/Config.wtf Set portal is gone.

test 2 same client Config.wtf reset to normal
launch World of Warcraft Launcher.exe Battlenet app launches.. login with EU test ID
in game wrong realm get EU realm list .. login character.. exit client
WTF/Config.wtf only changes gametip and realmname .. playing in EU with US settings!

test 3 same client config.wtf reset to normal
launch battlenet desktop app.. battlenet region = US login with EU test account
verify game settings are correct in install and game play directories
{Note with 2 clients the launcher frequently modifies the directories to the wrong client.. and often triggers a 10MB download before client ready to play}
results same as test 2

test 4 same client config.wtf reset to normal then change SET local "enGB"
launch battlenet desktop app .. battlenet region = US login with US existing battlenet account
launch game find WoW client setting up a new account.. region/realm/new character setups
log in on character and exit game.
retart battlenet desktop app find my US test account now has two starter game setups 1 EU 1 US

launcher.db changes but not always.. not sure what triggers the change.
  Reply With Quote
08-04-14, 10:07 PM   #15
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
Yes, finally beta time =)

-- Off-topic
I had to change the portal CVar in Config.wtf from "cn-test" to "public-test" in order to connect to the beta servers, even though I selected English as the installed/default language and located in Europe. Maybe because my Windows OS is in chinese?

Deleting the Config.wtf still made it rebuild with "cn-test"

Just wondering if other people had similar problems
  Reply With Quote
08-07-14, 07:46 AM   #16
Jarod24
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Jul 2012
Posts: 66
Was skimming over this post a while back and remembered it when i was working on updating my addon for patch 6.0.

Dont know if this has been said before or not but here we go.


GUID's are changing for the next expansion.
The new format for players are: Player:[server ID]:[player UID] (Example: "Player:976:0002FD64")

local strGUID = UnitGUID("player");

New GUID format: http://wowpedia.org/Patch_6.0.1/API_changes#Changes
Old documentation on GUID: http://wowpedia.org/GUID

Maybe you could use the server ID part of the guid to identify what server you are on (presuming that the ID are uniqe in the world and are persistant).
Combining that along with a hardcoded list of ID's in a library you could maybe get something working?
__________________
Author of IfThen, Links in Chat
  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