|
|
|
 |

June 5th, 2004, 09:13 PM
|
 |
Major General
|
|
Join Date: May 2002
Location: Linghem, Östergötland, Sweden
Posts: 2,255
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Re: The SE4 companion - Why the long wait?.
Quote:
Originally posted by Ed Kolis:
I feel so useless, coming up with new features for this program while being too lazy to work on my design analyzer program...
Then again, my job DOES involve programming all day so it's not something I really have much patience for when I get home...
|
Do you do some programming involving sending HTTP headers???
This is where I'm stuck right now:
code:
<link href="seiv.css" rel="STYLESHEET" type="text/css">
<html>
<head><title>Join Game: (Nearly Gods) The Conflict 5</title>
<META HTTP-EQUIV="Expires" CONTENT="-1">
<base target="_top">
</head>
<body bgcolor="#000000" text="#0099FF">
<H3>Upload your latest turn</H3>
Please upload your turn file; the sooner everyone uploads their turn,
the sooner the next turn can start! If you don't get your turn in on time,
you risk having the AI play for you.<P>
<B>Note</B>: Your turn file <em>should</em> be named
<B><CODE>NeGoC5_0001.plr</CODE></B>
or else you are probably uploading a turn for the wrong game!<P>
<FORM METHOD=POST enctype="multipart/form-data" ACTION='/GameUpload'>
Turn file (.plr): <input type=File name='file' size=20><BR>
<INPUT TYPE=HIDDEN NAME='command' VALUE='pturn'>
<INPUT TYPE=HIDDEN NAME='game' VALUE='147s84n'>
<INPUT TYPE=HIDDEN NAME='ok' VALUE='/text/index.jsp?menu=gamemenu.jsp%
3fgame=147s84n&body=gamebody.jsp%3fgame=147s84n'>
<INPUT TYPE=image src="img/sendturn.gif">
</FORM>
</body>
</html>
I'm trying to understand this code and see if it can help me:
http://www.matlus.com/scripts/websit...PartFormData&5
Currently the app uses an embedded hidden webbrowser that surfs and logins to the PBW server without user input.
Then it uses this procedure to download the files:
code:
function TForm1.GetInetFile
(const fileURL, FileName: String): boolean;
const BufferSize = 1024;
// Uses wininet
var
hSession, hURL: HInternet;
Buffer: array[1..BufferSize] of Byte;
BufferLen: DWORD;
f: File;
sAppName: string;
begin
//showmessage(fileUrl+'-'+FileName);
Result:=False;
sAppName := ExtractFileName(Application.ExeName);
hSession := InternetOpen(PChar(sAppName),
INTERNET_OPEN_TYPE_PRECONFIG,
nil, nil, 0);
try
hURL := InternetOpenURL(hSession,
PChar(fileURL),
nil,0,0,0);
try
AssignFile(f, FileName);
Rewrite(f,1);
repeat
InternetReadFile(hURL, @Buffer,
SizeOf(Buffer), BufferLen);
BlockWrite(f, Buffer, BufferLen)
until BufferLen = 0;
CloseFile(f);
Result:=True;
finally
InternetCloseHandle(hURL)
end
finally
InternetCloseHandle(hSession)
end;
end;
But now about the uploads, I can handle simple forms like the login form, but sending files is harder.
If I (the Se4 companion rather) inputs a filename with path in the textbox and presses send it says that it won't accept that (The full path), it accepts the filename only but then I don't know what happens, it says it has uploaded and executes but I can't see that I've sent any file... Does it create a dummy file?
I'll have to look what it is it receives at the PBW server, on monday, tomorrow 22 hour workday.
Any input is welcome!
[ June 05, 2004, 20:44: Message edited by: Ruatha ]
|

June 5th, 2004, 09:24 PM
|
 |
General
|
|
Join Date: Jan 2003
Location: Atlanta, GA
Posts: 3,499
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Re: The SE4 companion - Why the long wait?.
__________________
ALLIANCE, n. In international politics, the union of two thieves who have their hands so deeply inserted in each other's pocket that they cannot separately plunder a third. (Ambrose Bierce)
|

June 6th, 2004, 06:09 AM
|
 |
Major
|
|
Join Date: Jan 2004
Location: Taganrog, Russia
Posts: 1,087
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Re: The SE4 companion - Why the long wait?.
Ruatha, most likely my advice is stupid and incorrect, but afaik pbw will accept only quoted path in the form, ie
'c:\games\se4\savegames\blah_x.plr'
or with double quotes:
"c:\games\se4\savegames\blah_x.plr"
(i don't remember which variant is used, and pbw is offline at the moment, so I can't check it).
I don't think this will help, but you can try 
|

June 6th, 2004, 06:43 AM
|
 |
Major General
|
|
Join Date: May 2002
Location: Linghem, Östergötland, Sweden
Posts: 2,255
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Re: The SE4 companion - Why the long wait?.
Quote:
Originally posted by aiken:
Ruatha, most likely my advice is stupid and incorrect, but afaik pbw will accept only quoted path in the form, ie
'c:\games\se4\savegames\blah_x.plr'
or with double quotes:
"c:\games\se4\savegames\blah_x.plr"
(i don't remember which variant is used, and pbw is offline at the moment, so I can't check it).
I don't think this will help, but you can try
|
Can it be so easy???
I belive so, if so you are my Hero!!!!!
THANX
|

June 6th, 2004, 04:32 PM
|
 |
Major General
|
|
Join Date: May 2002
Location: Linghem, Östergötland, Sweden
Posts: 2,255
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Re: The SE4 companion - Why the long wait?.
Hi Aiken.
It doesn't seem to work.
With double quotes I get:
Cannot execute player command: Bad inputs to uploadPlayerTurn
and with single quotes:
Cannot execute player command: Filename uploaded was unexpected; expecting: se4ct2_0001.plr
Back to the black hole of despair again!
Edit:
I don't get it, now when I enter the full path it accepts it....without quotes!
I'm kinda pretty sure (92%) that I've tested that before and then it didn't work.
[ June 06, 2004, 15:54: Message edited by: Ruatha ]
|

June 6th, 2004, 04:52 PM
|
 |
National Security Advisor
|
|
Join Date: Jan 2001
Location: Ohio
Posts: 8,450
Thanks: 0
Thanked 4 Times in 1 Post
|
|
Re: The SE4 companion - Why the long wait?.
The single quote error message you are getting sounds promising. That's what you would get if you used the regular web interface and tried to upload the wrong file. Are you sure it's typing the filename correctly? It's including the path and the file extension?
__________________
I used to be somebody but now I am somebody else
Who I'll be tomorrow is anybody's guess
|

June 6th, 2004, 04:57 PM
|
 |
Major General
|
|
Join Date: May 2002
Location: Linghem, Östergötland, Sweden
Posts: 2,255
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Re: The SE4 companion - Why the long wait?.
Now it accepts everything without quotes, can't wait to get home and try it with an actual gamefile and see if it's the correct file it takes.
Now I'm at work and uses renamed textfiles.
The path is the same when I used single, double and no quotes
c:\temp\se4ct2_0001.plr
EDIT:
Guess I'll have to write down my assuredness that I'd tried this before to, oooh 48% now
And to think that I've tried all those strange HTTP header programming and teared my hear (Not actually but it sounds good) when it was this easy... if it is..
[ June 06, 2004, 16:01: Message edited by: Ruatha ]
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is On
|
|
|
|
|