Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GeoIP data update to the automatic build system #524

Merged
merged 2 commits into from Aug 27, 2018

Conversation

Arkshine
Copy link
Member

@psychonic It's based on your PR alliedmodders/sourcemod#390 but I'm unsure of paths. Will it be fine?

Copy link
Member

@psychonic psychonic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Paths should be okay.

You'll want to look at the other GeoIP-related changes that came to the SM version of the script after the original PR. It needed a couple of fixes for Windows, as well as being able to handle a failed download.

alliedmodders/sourcemod@c085444#diff-4f5469fd95ac0da70246f33896192d30
alliedmodders/sourcemod@e748d49#diff-4f5469fd95ac0da70246f33896192d30
alliedmodders/sourcemod@7008a56#diff-4f5469fd95ac0da70246f33896192d30

@Arkshine Arkshine merged commit c820db4 into alliedmodders:master Aug 27, 2018
@Arkshine Arkshine deleted the automatic-geoip-update branch August 27, 2018 13:07
OciXCrom pushed a commit to OciXCrom/amxmodx that referenced this pull request Sep 10, 2018
* Add GeoIP data update to the automatic build system

* Apply few fixes
@djearthquake
Copy link

I need the raw long and lat for my work. Are there any plans to add it as a native please? Otherwise what are the maths to take the lon and lat for distance back to raw? When I tried to converse it the maths do not prove themselves. In fact I keep a log and see it's picking up Zeros in 1 case. When I go and check the IP it does have data.

So for the distance calculations it is flawed already. I had to go back to my raw data to see.

LOG
Country: France, City: Prisse, Region: Bourgogne-Franche-Comte joined. |lat:214 lon:0|

Is 0 correct? Why 4.6 please?
214/46 = 4.6

https://sciencing.com/convert-latitude-longtitude-feet-2724.html

mmdblookup --file GeoLite2-City.mmdb --ip 109.25.197.97
"latitude":
46.321300
"longitude":
4.744700

@Nextra
Copy link
Contributor

Nextra commented Mar 12, 2019

@djearthquake There are Float:geoip_latitude(const ip[]) and Float:geoip_longitude(const ip[]) defined in geoip.inc. Do you have an issue with these?

@djearthquake
Copy link

Those 2 natives do not proof back to raw coordinates as stated in my initial post. Can you show me the maths please if they do? How is "longitude":4.744700 zero?

@Nextra
Copy link
Contributor

Nextra commented Mar 12, 2019

They do exactly what they are supposed to. You did something wrong in your code or you didn't install the GeoIP database correctly. Please ask for assistance in the Scripting Help section on our forums. Post more information about your setup and what you did, and provide your code so people can help you out.

@djearthquake
Copy link

amx_ctof and amx_ftoc. Is that a typo?

// native geoip_latitude(const ip[]);
static cell AMX_NATIVE_CALL amx_geoip_latitude(AMX *amx, cell *params)
{
int length;
char *ip = stripPort(MF_GetAmxString(amx, params[1], 0, &length));

const char *path[] = { "location", "latitude", NULL };
double latitude = lookupDouble(ip, path);

return amx_ftoc(latitude);

}

// native geoip_longitude(const ip[]);
static cell AMX_NATIVE_CALL amx_geoip_longitude(AMX *amx, cell *params)
{
int length;
char *ip = stripPort(MF_GetAmxString(amx, params[1], 0, &length));

const char *path[] = { "location", "longitude", NULL };
double longitude = lookupDouble(ip, path);

return amx_ftoc(longitude);

}

// native Float:geoip_distance(Float:lat1, Float:lon1, Float:lat2, Float:lon2, system = SYSTEM_METRIC);
static cell AMX_NATIVE_CALL amx_geoip_distance(AMX *amx, cell *params)
{
float earthRadius = params[5] ? 3958.0 : 6370.997; // miles / km

float lat1 = amx_ctof(params[1]) * (M_PI / 180);
float lon1 = amx_ctof(params[2]) * (M_PI / 180);
float lat2 = amx_ctof(params[3]) * (M_PI / 180);
float lon2 = amx_ctof(params[4]) * (M_PI / 180);

return amx_ftoc(earthRadius * acos(sin(lat1) * sin(lat2) + cos(lat1) * cos(lat2) * cos(lon2 - lon1)));

}

@Nextra
Copy link
Contributor

Nextra commented Mar 13, 2019

This is not a place for support. Please post in the forums. The AMXX code works, I tested it.

@djearthquake
Copy link

What AMXX code works? What did you test exactly? If this is not the place for support then why am I bothering testing your work for you for free and offering solutions here on this site already? How do you think we got here? The auto packaging of GeoIP sent it to the general public in a unusable form. I sorted that? Remember? The arrogance of AMXX does not match the greatness. Really guys. Good bye. I just showed you the native was returning a 0 when bash shows there is data. There is not anything wrong with my database copy or my work. Yours buddy had the problem. How quickly you forget. Why this code roundup on the forums? Then get here with this unappreciative attitude like only 3 people can program C++ really? How clannish. This site is the source of that code it's C++ not Small Pawn Alliedmodders. You want me to broadcast this further? I shredded my databases that I could use bash and pull coordinates because you are so sure of yourself and guess what it did not do anything. It's time you take more of my advice and less of your own. Your forums are a bigot troll factory. Clean it up. Your code and packaging.

@Arkshine
Copy link
Member Author

Arkshine commented Mar 13, 2019

Helping is welcomed and appreciated, but please do it the proper way.
Answering after a merged commit is not helpful and make difficult to track the discussion/problem.

If you have an issue, always go there: https://github.com/alliedmodders/amxmodx/issues
It's important.

For scripting related questions, the forum is also a good place, as stated Nextra.

In your case, make sure you have the latest city database from Maxmind site (we know if there an issue with the current shipped database).

I tested your IP and it worked as expected:

L 03/13/2019 - 14:07:42: [test.amxx] lat = 46.321300
L 03/13/2019 - 14:07:42: [test.amxx] long = 4.744699
#include <amxmodx>
#include <geoip>

public plugin_init()
{
    new const ip[] = "109.25.197.97";

    new const Float:lat = geoip_latitude(ip);
    new const Float:long = geoip_longitude(ip);

    log_amx("lat = %f", lat);
    log_amx("long = %f", long);
}

Note: for debugging, you can dump your IP data directly in the console: geoip dump <ip>.

If you think there is a bug, please create an issue instead, elaborate as much as possible, and show your code as well.

@alliedmodders alliedmodders locked as too heated and limited conversation to collaborators Mar 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants