WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Detect Current Region (https://www.wowinterface.com/forums/showthread.php?t=48877)

jaliborc 01-27-14 11:28 AM

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?

Resike 01-27-14 11:43 AM

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.

Dridzt 01-27-14 01:04 PM

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 :p

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

jaliborc 01-27-14 01:14 PM

Quote:

Originally Posted by Resike (Post 290252)
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!

Quote:

Originally Posted by Dridzt (Post 290254)
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 :p

If you have been using it, then it's good enough for me!

Vlad 01-28-14 07:52 AM

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

Nimhfree 01-29-14 12:24 PM

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.

Lombra 01-29-14 05:06 PM

But for any EU realm, the EU realm list will be used, no? Am I missing the point?

jaliborc 01-30-14 06:53 AM

Quote:

Originally Posted by Vlad (Post 290271)
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.

Quote:

Originally Posted by Lombra (Post 290302)
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.

Rainrider 01-31-14 01:19 PM

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.

Resike 02-01-14 05:54 AM

Quote:

Originally Posted by Rainrider (Post 290342)
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.

jaliborc 02-01-14 06:45 AM

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.

Phanx 02-01-14 07:11 AM

Quote:

Originally Posted by jaliborc (Post 290363)
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.

Quote:

Originally Posted by Resike (Post 290361)
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.

Rainrider 02-01-14 09:14 AM

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.

jaliborc 02-01-14 01:41 PM

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.

Simca 06-06-14 02:24 PM

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.

Kaelten 07-19-14 02:12 PM

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. :)

Bringer 07-22-14 07:07 PM

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.

Kaelten 07-22-14 09:48 PM

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.

Lombra 07-23-14 04:43 AM

I can only confirm that my portal is set to EU when I log my US trial, normally playing on EU accounts.

Phanx 07-23-14 06:37 AM

Quote:

Originally Posted by Kaelten (Post 294261)
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.


All times are GMT -6. The time now is 03:43 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI