Topic: X, Y Coordinates  (Read 7704 times)

0 Members and 1 Guest are viewing this topic.

DarkElf

  • Guest
X, Y Coordinates
« on: January 17, 2003, 12:02:53 am »
Is there any way to get the X and Y coordinates in a D2 mission.

I don't mean the briefing. I can pull them up in the briefing, but they are displayed in the format 1x.1y, and I don't think there is a way for me to make use of it.

I want to assign the X Coordinate to a variable and a Y Cooridinate to a variable, but I can't find where they are kept in the mission API.

I have found a way to put SQL Queries into a mission, but I need to have the X and Y coordinates to do anything with the map.

clintk

  • Guest
Re: X, Y Coordinates
« Reply #1 on: January 17, 2003, 07:58:25 am »
I have a horrible feeling that the tMissionInfo class isn't updated with this information from D2.

Does the SQL database hold a record of where a player is ?

You could inform your SQL database that the player has lost a mission, locate their position by querying the database and then updating the appropriate record.

Hope I'm not talking cr*p here  

NuclearWessels

  • Guest
Re: X, Y Coordinates
« Reply #2 on: January 17, 2003, 08:41:13 am »
Yeah, after a horrific amount of experimentation I finally gave up on trying to determine hex coordinates and/or player identity in-mission.  If you have a break-through we'd LOVE to hear it!

dave
 

DarkElf

  • Guest
Re: X, Y Coordinates
« Reply #3 on: January 17, 2003, 09:28:21 am »
Thanks NW, and ClintK!

I just may have....

Any way I can get a pilots Metaverse ID number of the pilot or of the ship hes flying?

If so, I CAN get the X, Y coordinates.

I did look on your site NW and saw this:

Code:

tShipInGame         Info.fPlayerFleet[3]; // tShipInGame can record nearly everything known about the ship,
                                                    // - position, type, name, BPV, human-controlled, meta-id,
                            // and also has some interesting fields I haven't played with,
                             // particurly fDisplayOnMap (a Boolean variable...)



Forgive me, I'm still a little new with C++...if you could post on how I could make use of this, please. I'm still learning as I go.
« Last Edit: January 17, 2003, 09:42:07 am by DarkElf »

NuclearWessels

  • Guest
Re: X, Y Coordinates
« Reply #4 on: January 17, 2003, 10:29:26 am »
Sigh.  That was written  in the blissful days when I still believed the comments in the API

No - the assorted methods/fields do NOT, unfortunately, get updated with any of that kind of information.
You can set the values inside the mission, and subsequently look up the values you just set,  but that's kinda pointless for the dynaverse.

dave
 

DarkElf

  • Guest
Re: X, Y Coordinates
« Reply #5 on: January 17, 2003, 09:42:47 pm »
*Starts to laugh diabloically*

Guess what I just did....

Well, I'm close anyway.
« Last Edit: January 17, 2003, 10:03:53 pm by DarkElf »

NuclearWessels

  • Guest
Re: X, Y Coordinates
« Reply #6 on: January 17, 2003, 10:56:23 pm »
<starts the wave>

<begins bowing up and down>
WE ARE NOT WORTHY!
WE ARE NOT WORTHY!

Cool DarkElf!  
Keep us informed!

dave
 

DarkElf

  • Guest
Re: X, Y Coordinates
« Reply #7 on: January 17, 2003, 11:18:11 pm »
Here are the details:

I was looking through the API, and I guess you were right.  It doesn't look like there is anything we can make of use.

Well, then I started looking through the SQL Database Structure.

Table 'servcharacter' has something that IS unique. Field IPAddress. (duh!)

Having found something that is unique, I can now build my query.

SELECT CharacterLocationX FROM servcharacter WHERE IPAddress='<IP Address>' and wham!  We have our X Coordinate.
SELECT CharacterLocationY FROM servcharacter WHERE IPAddress='<IP Address>' and wham!  We have our Y Coordinate.

All we need to do is write some code to detect the IP Address of the machine, store it into a variable.  Then we can combine the strings to get our query.  Execute the query, and store the results.

This should open a plethora (at least for SQL servers)  of stuff we can access to the database.  An absolute ton.

I have found a script that will detect your IP Address, however, I am having difficulty with conversions.  I'm a novice, unfortuantely, which means I have to ask for help.

Code:

//Simpile(?) IP Detection Script
#include <stdio.h>
#include <WinSock.h>
#pragma comment(lib, "wsock32.lib")

int main(int argc, char *argv[])
{
   WORD wVersionRequested;
   WSADATA wsaData;
   char name[255];
   PHOSTENT hostinfo;
   wVersionRequested = MAKEWORD( 1, 1 );
   char *ip;

   if ( WSAStartup( wVersionRequested, &wsaData ) == 0 )
      if( gethostname ( name, sizeof(name)) == 0)
      {
         if((hostinfo = gethostbyname(name)) != NULL)
         {
            int nCount = 0;
            
            {
               ip = inet_ntoa (*(struct in_addr *)hostinfo->h_addr_list[nCount]);

               printf(ip);
               printf("\n");
            }
         }
      }
   return 0;
}



Any suggestions?  If anyone has some time to help me with this, my MSN is mpddarkelf@hotmail.com, or reach me by ICQ # 176763073
« Last Edit: January 17, 2003, 11:25:05 pm by DarkElf »

clintk

  • Guest
Re: X, Y Coordinates
« Reply #8 on: January 18, 2003, 06:40:56 pm »
Are you sure that you want to expose the SFC2 D2 DB Server Port on the intranet ?  

Writing mission results to a web service has also been considered, but those damn hackers would have a field day !!

Security would be an issue in anything that we do here.

Sorry to be so negative, but if a campaign was hacked after 4 weeks and all backups destroyed, we'd lose half the community  

DarkElf

  • Guest
Re: X, Y Coordinates
« Reply #9 on: January 18, 2003, 09:55:27 pm »
Your right, and Im trying to find a different way of getting a unique identifier.

Still working at it, will keep you posted.

Well at least it worked for a while....

UDF_Intruder

  • Guest
Re: X, Y Coordinates
« Reply #10 on: January 21, 2003, 04:30:24 pm »
DarkElf,
Your code is an old standard one using the Winsock Library to retrieve the local IP Address.

The Variable "IP" is used to hold the "raw" IP Address, and is then formatted to the "XXXX.XXXX.XXXX.XXXX" style before simply being printed to the screen.

One problem you'll run into is multiple IP's, such as a PC in a LAN.

I am by no means an expert in C++, but have written a few things.  (A couple of SFC scripts too)

I am also watching your exploits with SQL with much interest. I gave up scripting because I didn't know enough about the API to make it do what I wanted. Besides, the D2 was really broke.

Since then I have turned my attention to SQL. Figured I would attack the problem from the other end.

An idea for db security might be treating the server like an Object in C.
Have a separate Database Server  handle the transactions.

My db Server recognizes 2 users...
1 PC runs a number of scripts simulating "background" AI's managing the Economic Activities of the Objects in the database.
the second is going to be the "Security Guard" that handles transactions between the db and players, once I can figure it out. It will be a Server unto itself for communicating with scripts external to the LAN, and relays acceptable transactions to/from the Main Database Server.

This way you encapulate the Dynaverse Database and only transactions from the intermediary are accepted. Hacking the intermediary won't give you access to the database, and the server's ports aren't accessible.

A Web Server could also request data that way to use in presenting Maps and other pages.

My Test Database is a map 150 LY across, centered on SOL and contains over 5000 Stars.
The BIG db has over a billion and a half stars on a map 1300 LY wide.

My goal is to augment the Dynaverse Map Mechanics with a more realistic set of rules for Economic and Defense values, install AI's to manage commerce (making convoys a REAL deal), and hopefully removing the "created" AI's for missions.

How's that?

   

FPF_TraceyG

  • Guest
Re: X, Y Coordinates
« Reply #11 on: January 21, 2003, 05:22:48 pm »
They sound like pretty good ideas.. I'd be interested in any other ideas you have on how you might implement this.. ;-)  

DarkElf

  • Guest
Re: X, Y Coordinates
« Reply #12 on: January 21, 2003, 05:34:58 pm »
Please take a look in the Dynaverse 2 Experiences forum.

I did find a workaround, please see the thread "Breaking new ground with SQL".