MantisBT - opensim
View Issue Details
0008810opensim[REGION] Script Functionspublic2020-11-15 14:132020-11-18 21:43
Gezebu MindBlue 
 
lowminoralways
newopen 
linuxfedora32
 
 
Version: OpenSim 0.9.2.0 Yeti Dev 08b06ec (SIMULATION/0.3 - SIMULATION/0.8)
Grid (Multiple Regions per Sim)
BulletSim
YEngine
Mono / Linux64
6.x
Firestorm 6.3.9.58205
0008810: osGetAgentCountry ...
The documentation says that "The country information must be added to grid database using external user admin tools", but in the database not exist the necessary field to added this information in the UserAccounts table, and userdata does not have any field. The wiki also does not provide information about which table and name the field for that information should be created. The command create user also does not give the possibility to enter the data. It could be convenient the existence of the command modify user, to be able to modify something more than the password or the email.

In the case of an existing user, osGetAgentCountry will not return any value, whitout errors.
But in the case of an Npc, an exception occurs that disables the script:

18:25:36 - [YEngine]: Exception while running 7a1ee1ee-227f-4e51-ba7a-177164479b28
NullReferenceException: Object reference not set to an instance of an object
Prim: <GeZ_Sensor_HUD_1.2>, Script: <GeZ_Sensor_HUD_1.2_2020>, Location: GeZ Sandbox <129,123,22>
Script must be Reset to re-enable.
  at OpenSim.Region.ScriptEngine.Shared.Api.OSSL_Api.osGetAgentCountry (OpenSim.Region.ScriptEngine.Shared.LSL_Types+LSLString id) [0x000ef] in <4690fe399e5d43b0b1cd4c167b2b609b>:0
  at OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass.osGetAgentCountry (OpenSim.Region.ScriptEngine.Shared.LSL_Types+LSLString agentId) [0x00001] in <d73150d16678418babf4a68895cdf550>:0
  at (wrapper dynamic-method) System.Object.avatar_info(key)(XMRInstanceSuperType,string)
  at (wrapper dynamic-method) System.Object.default listen(OpenSim.Region.ScriptEngine.Yengine.XMRInstAbstract)
  at OpenSim.Region.ScriptEngine.Yengine.XMRInstAbstract.CallSEH () [0x00050] in <c9cff9724af24220b5e04d8ee9bad7de>:0
  at OpenSim.Region.ScriptEngine.Yengine.XMRInstance.StartEx () [0x00009] in <c9cff9724af24220b5e04d8ee9bad7de>:0System.NullReferenceException: Object reference not set to an instance of an object
  at OpenSim.Region.ScriptEngine.Shared.Api.OSSL_Api.osGetAgentCountry (OpenSim.Region.ScriptEngine.Shared.LSL_Types+LSLString id) [0x000ef] in <4690fe399e5d43b0b1cd4c167b2b609b>:0
  at OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass.osGetAgentCountry (OpenSim.Region.ScriptEngine.Shared.LSL_Types+LSLString agentId) [0x00001] in <d73150d16678418babf4a68895cdf550>:0
  at (wrapper dynamic-method) System.Object.avatar_info(key)(XMRInstanceSuperType,string)
  at (wrapper dynamic-method) System.Object.default listen(OpenSim.Region.ScriptEngine.Yengine.XMRInstAbstract)
  at OpenSim.Region.ScriptEngine.Yengine.XMRInstAbstract.CallSEH () [0x00050] in <c9cff9724af24220b5e04d8ee9bad7de>:0
  at OpenSim.Region.ScriptEngine.Yengine.XMRInstance.StartEx () [0x00009] in <c9cff9724af24220b5e04d8ee9bad7de>:0
  
key npc_uuid = "8c5a010c-4126-4bfa-babe-5c1d44c9026d";
default
{
    state_entry()
    {
        llOwnerSay(llKey2Name(npc_uuid)+" country: "+osGetAgentCountry(npc_uuid));
    }
}
No tags attached.
child of 0008656new  osDetectedCountry and osGetAgentCountry return empty response 
patch NPC-does-not-have-a-country.patch (1,280) 2020-11-15 15:27
http://opensimulator.org/mantis/file_download.php?file_id=5011&type=bug
png user_country.png (25,389) 2020-11-15 20:18
http://opensimulator.org/mantis/file_download.php?file_id=5012&type=bug
png
Issue History
2020-11-15 14:13Gezebu MindBlueNew Issue
2020-11-15 15:24Gezebu MindBlueDescription Updatedbug_revision_view_page.php?rev_id=9452#r9452
2020-11-15 15:26tampaNote Added: 0037150
2020-11-15 15:27tampaFile Added: NPC-does-not-have-a-country.patch
2020-11-15 16:02Gezebu MindBlueNote Added: 0037152
2020-11-15 18:39djphilRelationship addedchild of 0008656
2020-11-15 18:46djphilNote Added: 0037153
2020-11-15 18:52djphilNote Edited: 0037153bug_revision_view_page.php?bugnote_id=37153#r9454
2020-11-15 18:52djphilNote Edited: 0037153bug_revision_view_page.php?bugnote_id=37153#r9455
2020-11-15 18:53djphilNote Edited: 0037153bug_revision_view_page.php?bugnote_id=37153#r9456
2020-11-15 19:17djphilNote Edited: 0037153bug_revision_view_page.php?bugnote_id=37153#r9462
2020-11-15 19:56djphilNote Added: 0037159
2020-11-15 20:17Gezebu MindBlueNote Added: 0037161
2020-11-15 20:18Gezebu MindBlueFile Added: user_country.png
2020-11-15 20:23djphilNote Added: 0037162
2020-11-15 20:40djphilNote Added: 0037163
2020-11-15 20:41djphilNote Edited: 0037163bug_revision_view_page.php?bugnote_id=37163#r9464
2020-11-16 08:56tampaNote Added: 0037169
2020-11-18 21:27djphilNote Added: 0037200
2020-11-18 21:43djphilNote Added: 0037201
2020-11-18 21:44djphilNote Edited: 0037201bug_revision_view_page.php?bugnote_id=37201#r9492
2020-11-18 21:48djphilNote Edited: 0037200bug_revision_view_page.php?bugnote_id=37200#r9494
2020-11-18 21:54djphilNote Edited: 0037201bug_revision_view_page.php?bugnote_id=37201#r9495
2020-11-18 22:14djphilNote Edited: 0037201bug_revision_view_page.php?bugnote_id=37201#r9496

Notes
(0037150)
tampa   
2020-11-15 15:26   
The key it is looking for is called "UserCountry" which should be equal to the field name, now I suspect that is a varchar255, don't think it matters where it is placed in the database. Don't see this being handled anywhere on input so I think you can only do that directly through the database at the moment.

In regards to the npc thing, yeah it seems the ossl implementation never checks if the scenepresence is an npc, easy fix though. I'll attach a patch you can try.
(0037152)
Gezebu MindBlue   
2020-11-15 16:02   
right. add the field UserCountry in UserAccounts make osGetAgentCountry work...
(0037153)
djphil   
2020-11-15 18:46   
(edited on: 2020-11-15 19:17)
Can you clarify exactly what we need to do for this function to work properly.
I had reported this issue in the past but it was never really resolved (mantis 0008656).
So I would be happy to see it finally work properly as well as osDetectedCountry.

(0037159)
djphil   
2020-11-15 19:56   
I imagine this could be added to the Tampa patch to also cover the NPCs for the osDetectedCountry function.

- if (detectedParams == null)
+ if (detectedParams == null || detectedParams.IsNPC)
(0037161)
Gezebu MindBlue   
2020-11-15 20:17   
@djphil as said tampa, you need add the UserCountry column in the UserAccounts table... but this user information can only be added manually. i used phpmyadmin.
(0037162)
djphil   
2020-11-15 20:23   
Yes I did that as I explained in detail here 0008656
Nevertheless it remains very imprecise.
Is this going to be automated or will we always have to do it manually?
How should the field be filled in, a form, a service?
Little information on this subject, only drop-by-drop informations.
(0037163)
djphil   
2020-11-15 20:40   
(edited on: 2020-11-15 20:41)
If we want to make this feature work, it is normal I find that we get the correct information to make it work correctly and thus avoid possible problems.

An example when creating the "UserCountry" field, we could leave it empty by default or assign it a default value like "Unknow".
Is it better to do this or not ...?

Tampa talks about a varchar 255 but I don't know of any country with such a long name.
Would varchar 32 or 64 not be more than enough?

Another question, will this be automatic or will we always have to add this field manually?

The information on the wiki does not speak of creating a "UserCountry" field manually in the "UserAccount" database. To date, the wiki speaks only of an "external user admin tools" without giving more details. It is very imprecise.

(0037169)
tampa   
2020-11-16 08:56   
One thing to automate this would be to crawl the robust.log regularly for the logins and test them against IP geolocation and insert into the field then. That's not all that difficult to accomplish, but it relies on databases and external information. OpenSim does not implement anything relying on a service that could go away at any point(apart from vivox lol) so this is unlikely to happen.

I suspect one could also use AgentPrefs as reference to determine if someone is really from Spain when their viewer language is french, but that's all external and a lot easier to accomplish with php or bash.
(0037200)
djphil   
2020-11-18 21:27   
(edited on: 2020-11-18 21:48)
There are free databases of ip countries (city, long, lat, etc ...) in different formats such as json, csv, sql, db, dll, etc ...
It can be downloaded from the internet and free of charge.
Opensim could download this and include it.

In this case Opensim would not depend on any external service.

(0037201)
djphil   
2020-11-18 21:43   
(edited on: 2020-11-18 22:14)
A similar example is GeoIP from php

You only download the "GeoLite2-City.mmdb" file and the "geoip2.phar" file once and add them to your php folder
You also add the extension "php_geoip.dll" in php/ext and activate it in php.ini (for windows users).
Then you can use all the geoip functions provided by php (see https://www.php.net/manual/fr/book.geoip.php [^]) and you don't depend on any external service and you don't have to download anything ...