POP EDITION LEVEL HELP

kamil9595pl
Sheikh
Sheikh
Posts: 36
Joined: July 31st, 2013, 5:28 pm

Re: POP EDITION LEVEL HELP

Post by kamil9595pl »

when when when when? ? ? :)

[Edit: Removed 200 smilies from this post. --Norbert]
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5786
Joined: April 9th, 2009, 10:58 pm

Re: POP EDITION LEVEL HELP

Post by Norbert »

kamil9595pl wrote:when when when when? ? ? :)

[Edit: Removed 200 smilies from this post. --Norbert]
Tomorrow, probably.
kamil9595pl
Sheikh
Sheikh
Posts: 36
Joined: July 31st, 2013, 5:28 pm

Re: POP EDITION LEVEL HELP

Post by kamil9595pl »

exactly please please
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5786
Joined: April 9th, 2009, 10:58 pm

Re: POP EDITION LEVEL HELP

Post by Norbert »

David, I'm trying to create a video on how to use PR, but PR isn't cooperating.
See the main_background.zip attached to this post.

First of all, PR 1.1 and PR 1.3 react differently to my commands.

This is PR 1.1:

Code: Select all

$ PR-1.1/src/bin/pr --resource=PR-1.1/src/bin/resources.xml --import=PoP1OPEN/ PoP1/TITLE.DAT 
Princed resources (PR) v1.1 GNU/Linux
(c) Copyright 2003 - 2005 Princed Development Team
http://www.princed.com.ar

Importing 'PoP1/TITLE.DAT' from 'PoP1OPEN/'
File TITLE.DAT already exists. Replace? [Yes/no/all]:y
Result: 12 files with errors (12)
This is PR 1.3:

Code: Select all

$ PR-1.3/src/bin/pr --resource=PR-1.3/src/bin/resources.xml --import=PoP1OPEN/ PoP1/TITLE.DAT 
Princed resources (PR) v1.3 GNU/Linux
(c) Copyright 2003-2012 Princed Development Team
http://www.princed.org

Importing 'PoP1/TITLE.DAT' from 'PoP1OPEN/'
File TITLE.DAT already exists. Replace? [Yes/no/all]:y
Result: Success (0)
Both touch the TITLE.DAT file in the PoP1/ directory, but neither of them actually change TITLE.DAT.

Your thoughts?
Attachments
main_background.zip
main background, old and new
(27.36 KiB) Downloaded 195 times
David
The Prince of Persia
The Prince of Persia
Posts: 2877
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: POP EDITION LEVEL HELP

Post by David »

Now this is odd: The image with "not working" written on it works for me (under Windows) with both PR 1.1 and PR 1.3, and both say "Success (0)".
Maybe try without the slash after PoP1OPEN?
But PR worked when you made your mod, didn't it? And now it suddenly doesn't? How can that be? Did you use some other version of PR?
How do you check whether the file changes? With the file size, or by starting the game?
Weird... :?
Anyway, I will reboot to Ubuntu and try it there.

The headers of the two bmp files differ in only two things:
- "Image size in bytes", but it's not used by PR.
- "Important colours", but it's not used by PR either.
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5786
Joined: April 9th, 2009, 10:58 pm

Re: POP EDITION LEVEL HELP

Post by Norbert »

David wrote:Maybe try without the slash after PoP1OPEN?
Doesn't change the outcome.
David wrote:But PR worked when you made your mod, didn't it? And now it suddenly doesn't? How can that be? Did you use some other version of PR?
I don't know why it's no longer working.
I used GIMP 2.6 and PR 1.3.
David wrote:How do you check whether the file changes?
With cmp, between the original and the PR 1.1 output, the original and the PR 1.3 output, and the PR 1.1 output and the PR 1.3 output.
They are all the same. PR only touches them, so only their date/time flags change.
I've also started the game for all versions. (Deliberately changed the title's main background to make 100% sure I'd immediately have to see the change if there was any.)
David wrote:Anyway, I will reboot to Ubuntu and try it there.
Cool, it'll be interesting to see if you can replicate it.
David
The Prince of Persia
The Prince of Persia
Posts: 2877
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: POP EDITION LEVEL HELP

Post by David »

I downloaded PR 1.3 from http://www.popot.org/other_useful_tools.php?tool=PR.
When I compiled it, I got some warnings:

Code: Select all

Compiling the POP1 16 colors palette class support...
In file included from /usr/include/string.h:640,
                 from lib/object/palette/pop1_4bit.c:39:
In function ‘memcpy’,
    inlined from ‘paletteGetColorArrayForColors’ at lib/object/palette/pop1_4bit.c:230:
/usr/include/bits/string3.h:52: warning: call to __builtin___memcpy_chk will always overflow destination buffer

Compiling prince level files support (plv)...
lib/formats/plv.c: In function ‘readPlv’:
lib/formats/plv.c:211: warning: incompatible implicit declaration of built-in function ‘free’
The first warning refers to a function that is never used, so I wrapped it between #if 0 and #endif.
I added a #include <stdlib.h> line to plv.c to fix the second warning.

And when I ran it:

Code: Select all

nagy@nagy-desktop:~/david/prince/pr-bug$ pr13/pr --resource=pr13/resources.xml --import=resources prince1/TITLE.DAT 
Princed resources (PR) v1.3 GNU/Linux
(c) Copyright 2003-2012 Princed Development Team
http://www.princed.org

Importing 'prince1/TITLE.DAT' from 'resources'
File TITLE.DAT already exists. Replace? [Yes/no/all]:a
*** buffer overflow detected ***: pr13/pr terminated
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6(__fortify_fail+0x50)[0x32cd40]
/lib/tls/i686/cmov/libc.so.6(+0xe6c7a)[0x32bc7a]
/lib/tls/i686/cmov/libc.so.6(__fread_chk+0x120)[0x32c500]
pr13/pr[0x80595e7]
pr13/pr[0x8057afc]
pr13/pr[0x80558c2]
pr13/pr[0x804eba9]
pr13/pr[0x8048ead]
pr13/pr[0x805b405]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe6)[0x25bbd6]
pr13/pr[0x8048d11]
======= Memory map: ========
00245000-0039e000 r-xp 00000000 08:02 512034     /lib/tls/i686/cmov/libc-2.11.1.so
0039e000-003a0000 r--p 00159000 08:02 512034     /lib/tls/i686/cmov/libc-2.11.1.so
003a0000-003a1000 rw-p 0015b000 08:02 512034     /lib/tls/i686/cmov/libc-2.11.1.so
003a1000-003a4000 rw-p 00000000 00:00 0 
005c5000-005c6000 r-xp 00000000 00:00 0          [vdso]
009e9000-00a06000 r-xp 00000000 08:02 458866     /lib/libgcc_s.so.1
00a06000-00a07000 r--p 0001c000 08:02 458866     /lib/libgcc_s.so.1
00a07000-00a08000 rw-p 0001d000 08:02 458866     /lib/libgcc_s.so.1
00bad000-00bc8000 r-xp 00000000 08:02 463735     /lib/ld-2.11.1.so
00bc8000-00bc9000 r--p 0001a000 08:02 463735     /lib/ld-2.11.1.so
00bc9000-00bca000 rw-p 0001b000 08:02 463735     /lib/ld-2.11.1.so
08048000-0805e000 r-xp 00000000 08:02 295330     /home/nagy/david/prince/pr-bug/pr13/pr
0805e000-0805f000 r--p 00015000 08:02 295330     /home/nagy/david/prince/pr-bug/pr13/pr
0805f000-08060000 rw-p 00016000 08:02 295330     /home/nagy/david/prince/pr-bug/pr13/pr
08ea6000-08f2a000 rw-p 00000000 00:00 0          [heap]
b77de000-b77df000 rw-p 00000000 00:00 0 
b77ee000-b77f4000 rw-p 00000000 00:00 0 
bfc3f000-bfc54000 rw-p 00000000 00:00 0          [stack]
Félbeszakítva
Crash! Boom! Bang!

After "make clean" I recompiled PR with debugging enabled, so the stack trace would be a bit more informative...
I got multiple warnings like this: (I don't think this would cause any bugs, though.)

Code: Select all

include/common.h:149:1: warning: C++ style comments are not allowed in ISO C90
include/common.h:149:1: warning: (this will be reported only once per input file)
Guess what: this time PR worked without problems.

The release version still crashes.
So I tried gdb. It *does* show the function names:

Code: Select all

(gdb) bt
#0  0x0012d422 in __kernel_vsyscall ()
#1  0x00158681 in raise () from /lib/tls/i686/cmov/libc.so.6
#2  0x0015bab2 in abort () from /lib/tls/i686/cmov/libc.so.6
#3  0x0019224d in ?? () from /lib/tls/i686/cmov/libc.so.6
#4  0x00215d40 in __fortify_fail () from /lib/tls/i686/cmov/libc.so.6
#5  0x00214c7a in __chk_fail () from /lib/tls/i686/cmov/libc.so.6
#6  0x00215500 in __fread_chk () from /lib/tls/i686/cmov/libc.so.6
#7  0x080594f7 in readBmp ()
#8  0x08057a0c in objImage16Read ()
#9  0x08055882 in readObject ()
#10 0x0804eb69 in import_full ()
#11 0x08048e6d in prImportDatOpt ()
#12 0x0805b315 in main ()
So readBmp() is the suspect. (It's in src/lib/formats/bmp.c)
With some debugging I figured out that these lines crash PR:

Code: Select all

	ok=ok&&freadlong(&width    ,bitmap);
	ok=ok&&freadlong(&height   ,bitmap);
Guess what... width and height are declared as short:

Code: Select all

	unsigned short int height=0;
	unsigned short int width=0;
So I changed them to long.
(If freadlong was a function and not a macro, then this would have caused at least a warning, at least in debug mode when the -Wall -pedantic switches are used.)
So, reading a long into a short is a buffer overflow, but not always?
If this did not cause a problem earlier, but it does now... Maybe something was changed in gcc or in libc or in the Linux kernel? But it's just a thought...

After this, the release version worked without errors!

So I could not reproduce what happened to you, but found some other bug.
Perhaps you should fix this in your copy, and try again.

After this, I fixed all warnings that appear when compiling in debug mode.
If I release a next version then it will contain these fixes.
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5786
Joined: April 9th, 2009, 10:58 pm

Re: POP EDITION LEVEL HELP

Post by Norbert »

David wrote:Maybe something was changed in gcc or in libc or in the Linux kernel?
Could be.
David wrote:Perhaps you should fix this in your copy, and try again.
Tried that, still no success.

I'm going to test what I've been trying on another PC.
That second PC here runs Debian with all kinds of outdated stuff, and maybe that's what I currently need for PR to work.
[Edit: No, doesn't fix it the problem.]
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5786
Joined: April 9th, 2009, 10:58 pm

Re: POP EDITION LEVEL HELP

Post by Norbert »

Norbert wrote:I will create a video that shows what to do.
No video, but a text. Here it is.

As far as PR goes, do exactly what David says here.

Where he writes "Now you can edit the images." use GIMP.

Here is how to open images with GIMP:

Image
(mirror)

Only use colors from the Colormap, that you can open like this:

Image
(mirror)

To save, use export:

Image
(mirror)

Save over the old BMP and make sure you check this checkbox:

Image
(mirror)

That checkbox should always be checked.
User avatar
Jakim
Beylerbey
Beylerbey
Posts: 55
Joined: March 5th, 2011, 2:27 pm
Location: Poland
Contact:

Re: POP EDITION LEVEL HELP

Post by Jakim »

Anteceding complains: if that won't help you, then nothing will help you ;).
David
The Prince of Persia
The Prince of Persia
Posts: 2877
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: POP EDITION LEVEL HELP

Post by David »

from the chat:
Norbert wrote: (15:11:16) Norbert: @David: basically, some directories PR creates are all capitals and some are not
(15:11:29) Norbert: title is not, so my commands could never work
I still don't understand it.

Your command does not refer to the title directory, only title.dat .

Code: Select all

$ PR-1.3/src/bin/pr --resource=PR-1.3/src/bin/resources.xml --import=PoP1OPEN/ PoP1/TITLE.DAT 
And title.dat was also uppercase in my command:

Code: Select all

$ pr13/pr --resource=pr13/resources.xml --import=resources prince1/TITLE.DAT 
Or did you rename the title directory to TITLE?
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5786
Joined: April 9th, 2009, 10:58 pm

Re: POP EDITION LEVEL HELP

Post by Norbert »

David, you can ignore what I wrote about capitals. Here's what happened:
I was working on this script.
That script now works fine and I'm happy with it, but when I was still working on it one of its export related lines contained an error.
That error resulted in the PoP1OPEN/ (resources/) directory having the title/ directory inside yet another TITLE/ directory.
In other words, my import command should have been:

PR-1.3/src/bin/pr --resource=PR-1.3/src/bin/resources.xml --import=PoP1OPEN/TITLE/ PoP1/TITLE.DAT

Anyways, everything works now. I'm using my script from now on. I'm busy porting that script to Windows (.BAT file).
The only question that remains is: will kamil9595pl be able to understand your instructions combined with my screenshots?
I'm not getting my hopes up. :|
kamil9595pl
Sheikh
Sheikh
Posts: 36
Joined: July 31st, 2013, 5:28 pm

Re: POP EDITION LEVEL HELP

Post by kamil9595pl »

See my video, see where I am doing mistake please: ( help help help me me me( me )xd ;(
http://www.youtube.com/watch?v=fcw8bvWd-iY
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5786
Joined: April 9th, 2009, 10:58 pm

Re: POP EDITION LEVEL HELP

Post by Norbert »

kamil9595pl wrote:See my video, see where I am doing mistake please: ( help help help me me me( me )xd ;(
http://www.youtube.com/watch?v=fcw8bvWd-iY
As I commented under the video:
3:24 You can't do that.
You cannot change the colors in the Colormap.
You can only _use_ the colors in the Colormap to change the image.
Also, you still need to _import_ the images (the resources).
You only exported the images.
As David wrote here:
David wrote:After you finished editing, copy the following command and paste it into the command line and press enter.

Code: Select all

pr\pr.exe --resource=pr\resources.xml --import=resources prince\*.DAT
If you see the question Replace? [Yes/no/all]:, press a.
Wait until it stops.
Now start the game. You should see your edited graphics.
kamil9595pl
Sheikh
Sheikh
Posts: 36
Joined: July 31st, 2013, 5:28 pm

Re: POP EDITION LEVEL HELP

Post by kamil9595pl »

how to change the color from default pallette color :(
Locked