Author Topic: PQ SWAT source code mystery  (Read 6258 times)

0 Members and 1 Guest are viewing this topic.

Offline lance.ewing

PQ SWAT source code mystery
« on: May 27, 2015, 07:18:25 AM »
I thought I'd create a separate thread specifically for discussions and theories in relation to the mystery of where the PQ SWAT source code snippet came from.

The first question I have in relation to this is that I noticed that PQ SWAT appears to have the script in a patch folder. I decompiled by hand the disassembly that SCI Viewer was showing me. Would it be showing me the patch version or the one from the main RESOURCE files?

What I might do is decompile the other one and see if that is a closer match for the original source snippet.



Offline Collector

Re: PQ SWAT source code mystery
« Reply #1 on: May 27, 2015, 12:17:35 PM »
One way that you can make sure which one is which is to remove the patch before pointing SV at the game to extract the script. That way you will know that it is from the resource archive.
KQII Remake Pic

Offline lance.ewing

Re: PQ SWAT source code mystery
« Reply #2 on: May 27, 2015, 01:43:23 PM »
Okay, I've tried that and the hitNineShot method appears to be the same as what I decompiled earlier, which seems to suggest that it wasn't loading the patch version (although obviously this isn't conclusive since I haven't looked at the rest of the script).

Do we have a tool capable of manipulating the individual resources in a SCI32 game? For example, removing 325.SCR and 325.HEP from the PQ SWAT resource file and then adding the patch versions in? If I can load the patch versions into the main resource file then it seems like the easiest way of viewing the disassembly of the patch version, i.e. by then loading it up in SCI Viewer again.

What other options do we have for viewing the disassembly of a patch script from a SCI32 game?

Offline troflip

Re: PQ SWAT source code mystery
« Reply #3 on: May 27, 2015, 03:20:25 PM »
The version of SV.exe that I have shows both the original and patch files (if the patch files are in the same folder). i.e. if there is a 21.hep, and also a heap resource 21 in the package file, then there will be two entries in the heap section for 21.
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline lance.ewing

Re: PQ SWAT source code mystery
« Reply #4 on: May 27, 2015, 03:34:21 PM »
Interesting. It wasn't showing two entries for me at first. For Police Quest SWAT, the patch files are in a folder called PATCHES. It seems that SV doesn't pick them up from there. But I copied them out of that folder in to the main folder and now it is picking them up. The patch version of the script appears to have the line number information in it, so it is clearly a different file. I'm going to take a look at it now to see if hitNineShot is different in the patch version.

Offline lance.ewing

Re: PQ SWAT source code mystery
« Reply #5 on: May 27, 2015, 05:01:11 PM »
I've now decompiled the patch version by hand and it appears to be exactly the same as the version in the main resource. I assume therefore that the changes for the patch were to other parts of the same script. The only additional information that the patch version provides is the line numbers in the original source file, and also the file name of the original source file:

Original file name:   325.SC

Source code with line numbers:

Code: [Select]
750: (instance hitNineShot of Script
751:    (method (changeState newState)
752:       (switchto (= state newState)
753:          (
754:             (theGame handsOff:)
755:             (qualProd dispose:, delete:)
756:             (++ nineShotCntr)
757:             (if (== nineShotCntr 9) ; Assume local21 is nineShotCntr
758:                (qualList dispose:) ; Assume local20 is qualList
759:                (Bset fQualifiedSniper) ; Assume 24 is fQualifiedSniper
760:                (ego awardMedal: 256)
761:                (= local43 1) ; ?????
762:                (curRoom newRoom: 320) ; Assume global1 is curroom (or curRoom if its an OCR error or typo)
763:             else
764:                (messenger say: 0 0 88 0 self 320) ; Assume 88 is QUAL-HIT-9-C and 0 is ALL
765:             )
766:          )
767:          (
768:             (messenger say: 0 0 89 0 self 320) ; Assume 89 is QUAL-RELOAD-9-C and 0 is ALL
769:          )
770:          (
771:             (= qualList (List new:)) ; Assume local20 is qualList
772:             (qualProd setReal: qualProd 6)
773:             (theGame hands0n:) ; Assume global1 is called "theGame"
774:             (self dispose:)
775:          )
776:       )
777:    )
778: )

No idea what local43 is at this stage.

So what does this mean? It means that both the original and the patch version do not match the original source snippet that was in general circulation 15+ years ago. So either there were other versions of Police Quest SWAT released that had code that matches the original source code snippet, or the original source code snippet was a pre-released version of the source.
« Last Edit: May 27, 2015, 05:10:51 PM by lance.ewing »

Offline lance.ewing

Re: PQ SWAT source code mystery
« Reply #6 on: May 27, 2015, 05:34:07 PM »
The following are the two versions, i.e. decompiled from the game vs. the original source snippet, side by side for comparison:

Code: [Select]
750: (instance hitNineShot of Script ; (instance hitNineShot of Script
751:    (method (changeState newState) ;    (method (changestate newstate)
752:       (switchto (= state newState) ;       (switchto (= state newState)
753:          ( ;          (
754:             (theGame handsOff:) ;             (theGame handsOff
755:             (qualProd dispose:, delete:) ;             (qualProd dispose:,delete:)
756:             (++ nineShotCntr) ;             (messager say: ALL ALL QUAL-HIT-9-C ALL self 320)
757:             (if (== nineShotCntr 9) ;          )
758:                (qualList dispose:) ;          (
759:                (Bset fQualifiedSniper) ;             (++ nineShotCntr)
760:                (ego awardMedal: 256) ;             (qualList dispose:)
761:                (= local43 1) ;             (target1 dispose:)
762:                (curRoom newRoom: 320) ;             (messager say: ALL ALL QUAL-RELOAD-9-C ALL self 320)
763:             else ;          )
764:                (messager say: 0 0 88 0 self 320) ;          (
765:             ) ;             (if (== nineShotCntr 9)     
766:          ) ;                (Bset fQualifiedSniper)
767:          ( ;                (curroom newroom: ANGELES-TABLES)
768:             (messager say: 0 0 89 0 self 320) ;             else
769:          ) ;                (targetl view: 3329, setloop: 2, setcel: 0, posn: 495 370,
770:          ( ;                         setPri:  470, init: ((snipeplane casts?) at: 0) ftrInitializer)
771:             (= qualList (List new:)) ;                (= qualList (List new:))
772:             (qualProd setReal: qualProd 6) ;                (qualProd setReal: qualprod 6)
773:             (theGame hands0n:) ;                (theGame hands0n:)
774:             (self dispose:) ;                (self dispose:)
775:          ) ;             )
776:       ) ;          )
777:    ) ;       )
778: ) ;    )
; )


So the first 6 or so lines are the same, the last 8 or so lines are the same. It's the 15 lines in the middle that are a bit different. The same two (messager say:) calls appear in the same cases in each version. And in both we have the nineShortCntr being incremented and compared to 9.

One bit missing from the original source snippet is the (ego awardMedal: 256), which seems like a fairly important message.
« Last Edit: May 27, 2015, 07:46:41 PM by lance.ewing »

Offline MusicallyInspired

Re: PQ SWAT source code mystery
« Reply #7 on: May 27, 2015, 05:39:14 PM »
Could have been unfinished code.
Brass Lantern Prop Competition

Offline lance.ewing

Re: PQ SWAT source code mystery
« Reply #8 on: May 27, 2015, 05:53:40 PM »
Yeah, that's my thoughts as well, which to me seems to lend weight to the theory that it featured in a magazine or book at some point. It seems more likely that an article would feature unfinished code (as part of promoting the game before release) than for leaked source code to be unfinished. If it were leaked source code, we'd expect to see more than just one method, given that this script contains a lot more code (all of which would have been in a single source file). And for it to have been leaked code, it would have had to have been leaked part way through the development of the code, which seems unlikely.

So my current hunch is that  this did appear in a magazine or book at some stage and that someone manually typed it in to a text file. That seems more likely than OCR, given the nature of the syntax errors.

And It seems more likely to be a magazine article than a book since if it were a book, we would have identified it a long time ago. A magazine article is more difficult to track down.

Offline lance.ewing

Re: PQ SWAT source code mystery
« Reply #9 on: June 24, 2015, 02:33:08 PM »
While I've just thought of it, I'll add to this thread a suggestion that the PQ Swat code could potentially have come from "slack space" on an original game disk. That might explain why it seems unfinished and doesn't match the decompiled code. But given that SWAT was probably in the CDROM days, it would only be a valid suggestion if slack space occurred on CDROMs.

Offline MusicallyInspired

Re: PQ SWAT source code mystery
« Reply #10 on: June 24, 2015, 02:37:14 PM »
Yeah, SWAT was on 4 CDs and didn't have a floppy release.
Brass Lantern Prop Competition

Offline lance.ewing

Re: PQ SWAT source code mystery
« Reply #11 on: June 24, 2015, 02:51:50 PM »
Another thought on this. Earlier in this thread I mentioned that the script that this instance came from was included in a patch file on the game disk. This might increase the likelihood of it being in memory or on the hard disk from where it was copied and therefore potentially being included in slack. Presumably it was a last minute change.

Does anyone have any thoughts on why they might have included such patch files separately rather than rebuilding the RESOURCE files?

Offline Cloudee1

Re: PQ SWAT source code mystery
« Reply #12 on: June 24, 2015, 02:58:34 PM »
I was actually thinking about something very similar to this... Judging by the view offsets that are present in the view resources, I was theorizing the other day that it must have been easier to tweak the view properties and rebuild the resources than it was for them to just go into the scripts and change the x and y properties defined and then recompile the scripts. Made me think that they had a real aversion to compiling... maybe it took forever or was just simply a pain in the arse. But for the life of me, that was the only reason I could come up with why there would be an x and y offset on a single loop, single cel view. Kind of lines up with the idea that they would rather patch something than script it, compile it, and rebuild it.
« Last Edit: June 24, 2015, 03:00:53 PM by Cloudee1 »
Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline lance.ewing

Re: PQ SWAT source code mystery
« Reply #13 on: June 24, 2015, 03:33:16 PM »
Yeah, it probably was a painful process.

What about the possibility that their master disks for this generation of game were write-once CDs? When were re-writable CDs introduced? If it wasn't until after this (or if they were too expensive at the time), then maybe writing a few patch files to an already created master CD was cheaper and maybe quicker than burning a whole new CD.

When did the first patch files start appearing? Did the number increase after the CD versions were introduced?

Offline Collector

Re: PQ SWAT source code mystery
« Reply #14 on: June 24, 2015, 04:25:30 PM »
Might have also been a division of labor. They had to have patch disks that could be sent to customers or files that could be downloaded. Some times a patch disk was simply added to the package without changing anything else.

The first SCI patch file distributed was KQ4 (KQ4FIX), though the very first release of KQ4 does not recognize external patches. As you suggest, for CDs injecting patch files into the master image may have been quicker than replacing the largest file on the disc. We do have to take into account the tools and hardware of the time with the limitations that they had.
KQII Remake Pic


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.126 seconds with 23 queries.