Page 1 of 2

Filter bug

Posted: Tue Aug 12, 2008 12:13 am
by obsidean
I was screwing around with the code in the "fun with filters" thread to see if I could get that ore scan code working when I noticed something odd. The version of the code I was using that Periculi wrote puts out the message as intended.. but it does it even if there are no asteroids around, and for that matter it doesn't target asteroids that should contain ore.

If it was just a bit of bad coding that I could understand, but the exact same code in two different systems producing different results? That's just strange. On his machine (xp I believe) the code works perfectly well, on mine (win98se, everything else in the new version works fine btw) well it's basically as useful as a "hello world" program.

I'll post the whole extension just for that sake of it.

Code: Select all

<?xml version="1.0" ?>
<!DOCTYPE TranscendenceExtension
[
<!ENTITY itOrescanner			"0xD0B11000">

]>

<TranscendenceExtension UNID="0xD0B11200" version="0.99a">

<ItemType UNID="&itOrescanner;"
		name=				"Ore Scanner"
		level=				"5"
		value=				"7000"
		mass=				"1"
		frequency=			"uncommon"
		modifiers=			"Consumable"

		description=		"This device scans for ore in asteroids and can be used again."

		charges=			"1"
		valueCharges=		"true"
		>

	<Image imageID="&rsItems1;" imageX="192" imageY="96" imageWidth="96" imageHeight="96"/>

<Invoke> 
   (block (miningAsteroids guessAsteroid) 
   (setq miningAsteroids (sysFindObject gSource "t:asteroid")) 
   (setq miningAsteroids (filter miningAsteroids asteroid (objGetItems asteroid "*U +Ore"))) 

   (loop miningAsteroids 
      (block nil 
      (setq guessAsteroid (item miningAsteroids 0)) 
      (setq miningAsteroids (filter miningAsteroids asteroid (ls (objGetDistance asteroid gSource) (objGetDistance guessAsteroid gSource)))) 
      ) 
   ) 
   (objSetName guessAsteroid "Ore Detected") 
   (objSetIdentified guessAsteroid) 
   (objSendMessage gPlayership guessAsteroid "Ore detected!")
   (shpCancelOrders gPlayership) 
   (shpOrder gPlayership 'dock guessAsteroid) 
   ) 
   </Invoke>
</ItemType>

</TranscendenceExtension>

Posted: Fri Aug 15, 2008 8:30 pm
by Periculi
George this is a bigger problem than just a filter bug.

obsidean did some experiments and sent me this pm
Well I messaged you before about the problem I was having with that ore scanner extension I was trying to make and I recently discovered something interesting.

I used a trick from my c++ classes and added some messages that should pop up when different parts of the invoke statement are used:

Code:

<Invoke>
(block (miningAsteroids guessAsteroid)
(setq miningAsteroids (sysFindObject gSource "t:asteroid"))
(objSendMessage gPlayership guessAsteroid "Expletive 1 Deleted!")
(setq miningAsteroids (filter miningAsteroids asteroid (objGetItems asteroid "*U +Ore")))

(loop miningAsteroids
(block nil
(setq guessAsteroid (item miningAsteroids 0))
(objSendMessage gPlayership guessAsteroid "Expletive 2 Deleted!")
(setq miningAsteroids (filter miningAsteroids asteroid (ls (objGetDistance asteroid gSource) (objGetDistance guessAsteroid gSource))))
)
)
(objSetName guessAsteroid "Ore Detected")
(objSetIdentified guessAsteroid)
(objSendMessage gPlayership guessAsteroid "Expletive 3 Deleted!")
(shpCancelOrders gPlayership)
(shpOrder gPlayership 'dock guessAsteroid)
)
</Invoke>


As you can see each block has a message in the middle and this allowed me to make a discovery, for some reason the computer is skipping the loop completely, regardless of the amount of asteroids on the map or screen only messages 1 & 3 displayed. Does this help you figure anything out, maybe how to fix it?
I have no idea why his machine would ignore the loop, the code works fine for me- so how can I fix it for him? Do you have any idea why loops and other iterative functions would be failing to be performed on an older version of windows?

I am on a Vista, and obsidean is on something prior to XP- a bunch of mods I have made don't work at all for him, and it looks like we figured out why- unfortunately, on many mods I can't think of any other way to do things besides loops or looping through lists.

Any ideas on what to do to help fix this short of getting obsidean an upgrade would be nice.

Posted: Fri Aug 15, 2008 9:46 pm
by george moromisato
It's hard to know without more help debugging. I can think of a few avenues to try:

1. What is the value of miningAsteroids right before the loop? If it is Nil, then the loop would never execute.

2. How much memory is Transcendence using? Is it possible that the machine is running out of memory? What kind of machine is it? What OS is it running?

3. Are there other extensions or programs loaded?

4. In the second line, instead of "t:asteroid" try "t:populated" and see if it detects a station with ore in it (sell some ore to the nearest commonwealth station).

I think this is a memory problem.

Posted: Sat Aug 16, 2008 7:50 pm
by obsidean
Memory shouldn't be a problem, I've had only one other problem with an extension and that was with System26. I'm using win98se, and as i said I've only had one problem extension before.
4. In the second line, instead of "t:asteroid" try "t:populated" and see if it detects a station with ore in it (sell some ore to the nearest commonwealth station).
I tried this and it found the station.

I'm working on finding out the value of miningAsteroids, I should have it later, but since it found the station the first option seems likely.

Posted: Sun Aug 17, 2008 2:32 am
by obsidean
Ok, I found out why it's not going into the loop, the first section is reporting nil always when I use "t:asteroid", but it works when I use "t:populated".

I've tested it far from asteroids, near them, near floating ore newly blasted from the asteroid, and still it returns nil.

So, is there any way to fix that or is something just screwed up?

Posted: Sun Aug 17, 2008 3:04 am
by george moromisato
You are running out of memory.

There are hundreds of asteroids; but only a few populated stations. That's why it works for +populated.

Try increasing the size of your virtual memory file.

Posted: Sun Aug 17, 2008 3:29 am
by Aury
how much ram do you have?
using paging files would slow the game down though

Posted: Sun Aug 17, 2008 4:25 am
by Periculi
back to the memory limits again, eh? I am fairly certain that was why System26 didn't want to run for you either, obsidean.

Hopefully the new navigation computer mod will work for you!

Posted: Sun Aug 17, 2008 8:25 am
by FAD
I'm running Win98SE as well and I don't have any problems with the game or mod.

Obsidean, try setting your Virtual Memory so that Minimum is set to 60 (leave Windows to set the max, however). This will allow a constant "auxiliary" memory to buffer so you won't run out.

Posted: Mon Aug 18, 2008 3:36 pm
by digdug
here there is a nice article on windows 98 memory management and how to set vcache and virtual memory (and why)
http://aumha.org/win4/a/memmgmt.htm

hope it helps you :)

Posted: Tue Aug 19, 2008 12:42 am
by obsidean
I tried setting the size of my swap file, it actually made the game run worse, random freezes, sudden slowdowns and speedups. I never had a problem like that before I tried changing the virtual memory settings.

Posted: Tue Aug 19, 2008 12:55 am
by Fatboy
What was the size of it before, and what is it now.
What is your RAM amount.

Posted: Tue Aug 19, 2008 2:05 am
by obsidean
192 mb of ram and before I let windows manage the swap file

Now I have it set up for the swap file to be at least 200mb and for the computer to use the ram before the swap file.

Of course the extension still doesn't work, so I am going to quit trying to get it working.

Posted: Tue Aug 19, 2008 2:11 am
by Periculi
George mentioned adding an out-of-memory check to the sysFindObject in 099b- did you get the new version and try the mod with that?

Posted: Tue Aug 19, 2008 2:26 am
by obsidean
No, after I read about the save file corruption I decided to wait until he put out the fixed version.