Making a Protocol Handler for BZ2

Moderators: GSH, VSMIT, Red Devil, Commando

Post Reply
User avatar
Zero Angel
Attila
Posts: 1536
Joined: Mon Feb 21, 2011 12:54 am
Contact:

Making a Protocol Handler for BZ2

Post by Zero Angel »

So i've started on a little project to create something called a 'Protocol Handler' which is designed to launch BZ2 and direct connect to an IP when a special link is clicked on (e.g.: bz2game://ip.add.re.ss )

My InnoSetup contains the following registry code:

Code: Select all

Root: HKCR; Subkey: bz2game; ValueType: string; ValueData: "URL:Battlezone 2"; Components: protocolhandler; 
Root: HKCR; Subkey: bz2game; ValueType: string; ValueName: URL Protocol; Components: protocolhandler; 
Root: HKCR; Subkey: bz2game\DefaultIcon; ValueType: string; ValueData: {app}\bzone.exe,0; Components: protocolhandler; 
Root: HKCR; Subkey: bz2game\shell\open\command; ValueType: string; ValueData: """{app}\bzone.exe"" -nointro +connect ""%1"" +name {code:GetBZ2Name}"; Components: protocolhandler; 
Basically it works, sort of. When the special link is entered into the browser, BZ2 does indeed launch -- however I get an error saying that the game cannot find or execute bzone.cfg. This will typically happen if bzone.exe is launched from a different 'working directory' than the bz2 root directory itself -- in this case the working directory seems to be the user's desktop.

So I'd like to know if anyone has any ideas regarding BZ2 to launch using the correct folder when this method is employed.
Regulators
Regulate any stealin' of this biometal pool, we're damn good, too
But you can't be any geek off the street
Gotta be handy with the chains if you know what I mean
Earn your keep
User avatar
Red Spot
Attila
Posts: 1629
Joined: Mon Feb 21, 2011 6:14 pm
Location: The Netherlands

Re: Making a Protocol Handler for BZ2

Post by Red Spot »

Have it create a shortcut to desktop and launch it from there, possibly cleaning up the shortcut after its done, or at least have it check for an existing one before it makes a new one.
User avatar
Zero Angel
Attila
Posts: 1536
Joined: Mon Feb 21, 2011 12:54 am
Contact:

Re: Making a Protocol Handler for BZ2

Post by Zero Angel »

From what I understand, the protocol handler in hkey_classes_root cannot launch shortcuts directly. I've tried pointing it directly at a shortcut as well as using a string like "C:\Users\David\Desktop\Battlezone II.lnk" +connect "%1" +name Zero_Angel as well as cmd /c "C:\Users\David\Desktop\Battlezone II.lnk" +connect "%1" +name Zero_Angel. In cases where they would work from the run command dialog, they will return an error that bz2game is not a valid win32 application when used with the bz2game protocol handler.
Regulators
Regulate any stealin' of this biometal pool, we're damn good, too
But you can't be any geek off the street
Gotta be handy with the chains if you know what I mean
Earn your keep
User avatar
Nielk1
Flying Mauler
Posts: 2991
Joined: Fri Feb 18, 2011 10:35 pm
Contact:

Re: Making a Protocol Handler for BZ2

Post by Nielk1 »

Using this, a web based game list could allow direct launches of BZ2 to join said games.
User avatar
Zero Angel
Attila
Posts: 1536
Joined: Mon Feb 21, 2011 12:54 am
Contact:

Re: Making a Protocol Handler for BZ2

Post by Zero Angel »

Exactly.
Regulators
Regulate any stealin' of this biometal pool, we're damn good, too
But you can't be any geek off the street
Gotta be handy with the chains if you know what I mean
Earn your keep
User avatar
Cyber
Sabre
Posts: 202
Joined: Sun Feb 20, 2011 5:46 pm

Re: Making a Protocol Handler for BZ2

Post by Cyber »

Good idea. Very good.
Teamspeak 3: teamspeak.com
TS3 Server(Ugonland): 74.91.115.34
User avatar
Zero Angel
Attila
Posts: 1536
Joined: Mon Feb 21, 2011 12:54 am
Contact:

Re: Making a Protocol Handler for BZ2

Post by Zero Angel »

So i've been messing around with making the protocol handler work with TnT's mod selector tool using the following settings (for testing)

Please note that the double backslashes and backslash quotes are part of the .reg file format and are not present in the actual registry entries.

Code: Select all

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\bz2game]
@="URL:Battlezone 2"
"URL Protocol"=""

[HKEY_CLASSES_ROOT\bz2game\DefaultIcon]
@="D:\\Program Files (x86)\\Battlezone2\\bzone.exe,0"

[HKEY_CLASSES_ROOT\bz2game\shell]

[HKEY_CLASSES_ROOT\bz2game\shell\open]

[HKEY_CLASSES_ROOT\bz2game\shell\open\command]
@="\"C:\\Users\\david\\Downloads\\GRBZ2 Selector\\GRBZ2 Selector\\bzone.exe\" -nointro +connect %1 +name testguy"
So when I enter bz2game://222.222.222.222 in the browser, this is the result:

Code: Select all

Enter:   0 to Exit Program
Enter:   1 to launch: Normal BZ2

Select Mod Number:  1

launching D:\Program Files (x86)\Battlezone2\bzone.exe
with arguments: -nointro +connect bz2game://222.222.222.222/ +name testguy  -config bzone.cfg


Press any key to continue . . .
BZ2 launches properly, however does not establish a connection properly.

Now, does anyone know of a way, using the registry, to strip out everything but the IP address from the command line arguments that are passed to the bz2 launcher?
Regulators
Regulate any stealin' of this biometal pool, we're damn good, too
But you can't be any geek off the street
Gotta be handy with the chains if you know what I mean
Earn your keep
User avatar
General BlackDragon
Flying Mauler
Posts: 2408
Joined: Sat Feb 19, 2011 6:37 am
Contact:

Re: Making a Protocol Handler for BZ2

Post by General BlackDragon »

Did u try 222.222.222.222:17770?
Battlezone Classic Public Forums
*****General BlackDragon*****
User avatar
Ded10c
Recycler
Posts: 3815
Joined: Sun Feb 20, 2011 11:05 am
Location: Stoke-on-Trent
Contact:

Re: Making a Protocol Handler for BZ2

Post by Ded10c »

General BlackDragon wrote:Did u try 222.222.222.222:17770?
Just a guess, but I think he means that the problem is that bz2game:// gets passed as a part of the argument rather than just the IP.
battlezone.wikia.com needs your help!
User avatar
TnT
Drunken Constructor
Posts: 32
Joined: Sat Feb 19, 2011 5:55 pm

Re: Making a Protocol Handler for BZ2

Post by TnT »

ZA,

If I understand your goal correctly, you wish to have a webpage that lists possible hosts as links. A player would click the link and BZ should then launch using the given IP address. Based on this understanding, I have made a quick change to my Mod List program to incorporate a webbrowser that intercepts navigation to "bz2game://" and pulls the IP info from the link. The user can then choose to launch. I added a button to host as well that tells BZ to host using port 17770. There is also a checkbox to allow for for appending 17770 to the IP address.

You can download this at: http://sdrv.ms/SF3iFx

This version has two tabs, one to define the mods to run and the second is a browser control. The browser starts out on google (I don't like large blank screens). There is a button labeled "Load Bogus Webpage" click on that to bring up the links. This webpage is internal to the program. If you want to test it with addresses relevant to you, just create a webpage on your computer and put the full file path in the textbox and hit go.

If this of possible use to get people playing again, I am more than willing to clean this up for release.
User avatar
Zero Angel
Attila
Posts: 1536
Joined: Mon Feb 21, 2011 12:54 am
Contact:

Re: Making a Protocol Handler for BZ2

Post by Zero Angel »

Would you be able to get your program to properly detect if bz2game://ip.add.re.ss is passed to it and then strip out the bz2game:// portion that is forwarded to the real bzone.exe ?
Regulators
Regulate any stealin' of this biometal pool, we're damn good, too
But you can't be any geek off the street
Gotta be handy with the chains if you know what I mean
Earn your keep
Post Reply