Pandemic in Persia

User avatar
atrueprincefanfrom18
Site Shah
Site Shah
Posts: 1785
Joined: January 21st, 2020, 2:53 pm
Contact:

Re: Pandemic in Persia - In Progress

Post by atrueprincefanfrom18 »

YURA, are you getting the ZIP file and all the contents inside it correctly from PoPOT?
Love to create new MODS :)

My complete list of mods until now!

My channel. Do consider subscribing it! :)
YURA
The Prince of Persia
The Prince of Persia
Posts: 1425
Joined: February 9th, 2017, 11:12 pm

Re: Pandemic in Persia - In Progress

Post by YURA »

The author! This is the final result of the mod.... or will there be alterations again?
User avatar
atrueprincefanfrom18
Site Shah
Site Shah
Posts: 1785
Joined: January 21st, 2020, 2:53 pm
Contact:

Re: Pandemic in Persia - In Progress

Post by atrueprincefanfrom18 »

YURA wrote: February 26th, 2021, 6:10 pm The author! This is the final result of the mod.... or will there be alterations again?
The previous creation was perfect too, but as you and SuavePrince said, "it needs luck", so I altered it. I think it's done now, no more alterations in that level.

So, no. No more. Go ahead and play it ;)
Love to create new MODS :)

My complete list of mods until now!

My channel. Do consider subscribing it! :)
YURA
The Prince of Persia
The Prince of Persia
Posts: 1425
Joined: February 9th, 2017, 11:12 pm

Re: Pandemic in Persia - In Progress

Post by YURA »

atrueprincefanfrom18 wrote: February 26th, 2021, 6:13 pm
YURA wrote: February 26th, 2021, 6:10 pm The author! This is the final result of the mod.... or will there be alterations again?
The previous creation was perfect too, but as you and SuavePrince said, "it needs luck", so I altered it. I think it's done now, no more alterations in that level.

So, no. No more. Go ahead and play it ;)
Thanks! Make a link to the final version of the mod....
User avatar
atrueprincefanfrom18
Site Shah
Site Shah
Posts: 1785
Joined: January 21st, 2020, 2:53 pm
Contact:

Re: Pandemic in Persia - In Progress

Post by atrueprincefanfrom18 »

YURA wrote: February 26th, 2021, 8:38 pm
atrueprincefanfrom18 wrote: February 26th, 2021, 6:13 pm
YURA wrote: February 26th, 2021, 6:10 pm The author! This is the final result of the mod.... or will there be alterations again?
The previous creation was perfect too, but as you and SuavePrince said, "it needs luck", so I altered it. I think it's done now, no more alterations in that level.

So, no. No more. Go ahead and play it ;)
Thanks! Make a link to the final version of the mod....
This post. Download from attachment if PoPOT ZIP file is not showing any contents.
Love to create new MODS :)

My complete list of mods until now!

My channel. Do consider subscribing it! :)
David
The Prince of Persia
The Prince of Persia
Posts: 2848
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: Pandemic in Persia - In Progress

Post by David »

atrueprincefanfrom18 wrote: February 26th, 2021, 6:04 pm are you getting the ZIP file and all the contents inside it correctly from PoPOT?
This is what I see in the ZIP from PoPOT:
• Directly inside the ZIP is a folder called "0000236".
• Inside that, there are two folders, called "0000236" and "UpdatedPandemicInPersia".
• Both contain a full copy of the mod.

I see the same with the ZIP browser built into Windows 10, with Total Commander, and with 7-Zip.
What do you use to open ZIP files?


In 7-Zip, I see some differences between your attached UpdatedPandemicInPersia.zip and PoPOT's 0000236.zip:

0000236.zip
• The compression method is Deflate:Maximum.
• File permissions are -rw-rw-rw-.
• The directories have no modified date, attributes, method, characteristics, host OS, version, volume index, offset.
• The files have no characteristics.

UpdatedPandemicInPersia.zip
• The compression method is Deflate.
• File permissions are -rw-------.
• The single directory has modified date, attributes, method, characteristics, host OS, version, volume index, offset.
• The files have characteristics "UT 0x7875 : Descriptor". I don't know what that means.

Additionally, in 0000236.zip there are no separate entries for the directories, only for the contained files!
This might be why it you can't extract its contents.
The ZIP extractor you use might expect the directories to have separate entries.
David
The Prince of Persia
The Prince of Persia
Posts: 2848
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: Pandemic in Persia - In Progress

Post by David »

David wrote: February 27th, 2021, 9:16 pm Additionally, in 0000236.zip there are no separate entries for the directories, only for the contained files!
I have looked into the source of PoPOT to see why this could be.

I see it doesn't just put the uploaded ZIP unchanged into the downloads.
Instead it extracts the ZIP and makes a new ZIP from the extracted files.

The new ZIP file is created by submit.php, by this code:

Code: Select all

							$zip = new ZipArchive();
							$zip->open ($sZipFile, ZipArchive::CREATE|ZipArchive::OVERWRITE);
							$files = new RecursiveIteratorIterator
								(new RecursiveDirectoryIterator ($sZipPath),
								RecursiveIteratorIterator::LEAVES_ONLY);
							foreach ($files as $name => $file)
							{
								if (is_dir ($file) === FALSE)
								{
									$filePath = $file->getRealPath();
									$relativePath = substr ($filePath, strlen ($sZipPath) + 1);
									$zip->addFile ($filePath, $relativePath);
								}
							}
							$zip->close();
I think you should do the following changes:
• Change the LEAVES_ONLY option to SELF_FIRST, so directories are not skipped.
• Call addEmptyDir for directories, on an else branch.
If you look through the comments on the addFile page, some user examples show that they add the directory before the contained files.


The other question is, why is the mod in there twice?

The code does the following:
• Creates /tmp/0000236-tmp/ if it does not yet exist.
• Creates /tmp/0000236-tmp/0000236/ if it does not yet exist.
• Extracts the uploaded ZIP into /tmp/0000236-tmp/0000236/ .
• If there is only one thing in /tmp/0000236-tmp/0000236/ and it's a directory, then renames that directory to 0000236 .
In our case, /tmp/0000236-tmp/0000236/UpdatedPandemicInPersia/ is renamed to /tmp/0000236-tmp/0000236/0000236/ .
• Then the contents of /tmp/0000236-tmp/0000236/ are zipped.

But what happens if someone updates the same mod again, and the temp files are not deleted between the two updates?
The first three steps are the same:
• Creates /tmp/0000236-tmp/ if it does not yet exist.
• Creates /tmp/0000236-tmp/0000236/ if it does not yet exist.
• Extracts the uploaded ZIP into /tmp/0000236-tmp/0000236/ .
• But now there are *two* things in /tmp/0000236-tmp/0000236/ -- the freshly extracted UpdatedPandemicInPersia directory *and* the 0000236 directory from the previous go!
This is how they ended up in the ZIP!

At this part:

Code: Select all

						$sZipTmp = '/tmp/' . $sModCode . '-tmp';
						$sZipTmpF = $sZipTmp . '/' . $sModCode;
						if (file_exists ($sZipTmp) === FALSE)
						{
							if (mkdir ($sZipTmp, 0775) === FALSE)
								{ $sError = 'Cannot create "' . $sZipTmp . '".'; }
						}
You should first delete the directory named in $sZipTmp, if it exists, together with its contents.
User avatar
atrueprincefanfrom18
Site Shah
Site Shah
Posts: 1785
Joined: January 21st, 2020, 2:53 pm
Contact:

Re: Pandemic in Persia - In Progress

Post by atrueprincefanfrom18 »

David wrote: February 27th, 2021, 9:16 pm What do you use to open ZIP files?
I just use my default extractor for Ubuntu and I tried to first extract it and waited. It didn't do anything! No message, no alert, no notification.
Then I thought maybe my computer or PoPOT has some issues... So I tried creating another file good for uploading (removing apoplexy.bat, apoplexy.sh, LEVELS.BAK, QUICKSAVE.SAV and PRINCE.SAV) and gave it another name. Still after downloading, I couldn't extract it (and see the contents). I tried running this code:

Code: Select all

import requests
url = "https://www.popot.org/custom_levels/software/0000236.zip"

r = requests.get(url, stream = True)

print(r.content)
It printed out binary content along with file names. Now my programmer's brain understood something was wrong with my computer and maybe PoPOT is not responsible for this.

Is there any way I can fix this issue on my computer? (I tried writing the file on disk with Python (above code), but it didn't work.)
David wrote: February 27th, 2021, 9:16 pm In 7-Zip, I see some differences between your attached UpdatedPandemicInPersia.zip and PoPOT's 0000236.zip:
Maybe because it's downloaded from different sources (servers)? PoPOT and/or the forum's code might be modifying some permissions or something?
Love to create new MODS :)

My complete list of mods until now!

My channel. Do consider subscribing it! :)
David
The Prince of Persia
The Prince of Persia
Posts: 2848
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: Pandemic in Persia - In Progress

Post by David »

atrueprincefanfrom18 wrote: February 28th, 2021, 4:40 am I just use my default extractor for Ubuntu and I tried to first extract it and waited. It didn't do anything! No message, no alert, no notification.
If you use the extractor from the GUI, try running it from the command line instead.
(I think it's called file-roller.)
It might write some error message to the console, explaining why it doesn't do anything.

atrueprincefanfrom18 wrote: February 28th, 2021, 4:40 am I tried running this code:

Code: Select all

import requests
url = "https://www.popot.org/custom_levels/software/0000236.zip"

r = requests.get(url, stream = True)

print(r.content)
It printed out binary content along with file names.
You could download the file manually and then open it in a hex editor to see the same.

atrueprincefanfrom18 wrote: February 28th, 2021, 4:40 am (I tried writing the file on disk with Python (above code), but it didn't work.)
What do you mean by "didn't work"?
Did it create no file, or did it create an empty file (0 bytes)?
Or did it create a file with a size of about 675 kB, whose contents you can't extract?

atrueprincefanfrom18 wrote: February 28th, 2021, 4:40 am Is there any way I can fix this issue on my computer?
You could try using a different ZIP extractor.

atrueprincefanfrom18 wrote: February 28th, 2021, 4:40 am Maybe because it's downloaded from different sources (servers)? PoPOT and/or the forum's code might be modifying some permissions or something?
As I wrote in my previous post, PoPOT extracts the ZIP you upload to it, and it creates a new ZIP from the contents.

The main point is that PoPOT's ZIP does not contain separate entries for the directories.
(That's why the directories don't have dates, attributes, etc. in the ZIP from PoPOT.)
For example, the first entry in 0000236.zip is "0000236/0000236/LEVELS.DAT".
There is no separate entry for "0000236/0000236/" or "0000236/".


Try downloading the mod with the previous number: https://www.popot.org/custom_levels.php?mod=0000235
And also the mod with the next number: https://www.popot.org/custom_levels.php?mod=0000237

0000235.zip has an entry for the directory, the first entry is "0000235/".
0000237.zip has no entry for the directory, the first entry is "0000237/CDUNGEON.DAT".
Please try this and tell me whether you can extract these ZIPs.
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5745
Joined: April 9th, 2009, 10:58 pm

Re: Pandemic in Persia - In Progress

Post by Norbert »

Hi, going by what David writes (thanks for the info!), apparently the PoPOT code needs improvement.
I'll look into this today. Hopefully I'll understand what code modifications are necessary.
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5745
Joined: April 9th, 2009, 10:58 pm

Re: Pandemic in Persia - In Progress

Post by Norbert »

David wrote: February 27th, 2021, 9:16 pm• The files have characteristics "UT 0x7875 : Descriptor". I don't know what that means.
It appears to be an extensible data field used by Info-ZIP, namely EF_IZUNIX3, the 3rd generation Unix e.f., which stores the UID and GID ownership information.
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5745
Joined: April 9th, 2009, 10:58 pm

Re: Pandemic in Persia - In Progress

Post by Norbert »

Norbert wrote: February 28th, 2021, 1:17 pm Hi, going by what David writes (thanks for the info!), apparently the PoPOT code needs improvement.
I'll look into this today. Hopefully I'll understand what code modifications are necessary.
Should be fixed now.
The attached diff image shows my solution.
Attachments
submit_diff.png
YURA
The Prince of Persia
The Prince of Persia
Posts: 1425
Joined: February 9th, 2017, 11:12 pm

Re: Pandemic in Persia - In Progress

Post by YURA »

hello everyone! The author! Tell me what MOD you can play in 236 or another...there are 2 games!? Or rename the game as 1 and 2
User avatar
atrueprincefanfrom18
Site Shah
Site Shah
Posts: 1785
Joined: January 21st, 2020, 2:53 pm
Contact:

Re: Pandemic in Persia - In Progress

Post by atrueprincefanfrom18 »

YURA wrote: March 1st, 2021, 3:41 pm hello everyone! The author! Tell me what MOD you can play in 236 or another...there are 2 games!? Or rename the game as 1 and 2
Download from this post. Get the attachment instead of PoPOT.
Love to create new MODS :)

My complete list of mods until now!

My channel. Do consider subscribing it! :)
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5745
Joined: April 9th, 2009, 10:58 pm

Re: Pandemic in Persia - In Progress

Post by Norbert »

YURA wrote: March 1st, 2021, 3:41 pm hello everyone! The author! Tell me what MOD you can play in 236 or another...there are 2 games!? Or rename the game as 1 and 2
The contents of these directories is the exact same.
atrueprincefanfrom18, you could re-add your ZIP, because it's fixed now.
Post Reply