DFHack / dfhack

Memory hacking library for Dwarf Fortress and a set of tools that use it
Other
1.87k stars 475 forks source link

populations quantity wrong offset? #1648

Closed tsurezuregusa closed 4 years ago

tsurezuregusa commented 4 years ago

I do not know if this is a bug, but the problem in issue #1646 made me think this maybe is also wrong offset or something like that.

In df.global.world.populations there are many with quantity 10000001. This seems strange. Maybe should be 1.

[DFHack]# lua ~df.global.world.populations[0]
<local_population: 0x170c973d0>
type                     = 7
race                     = 4
plant                    = 4
quantity                 = 10000001
quantity2                = 10000001
flags                    = <local_population.T_flags: 0x170c973dc>
population               = <world_population_ref: 0x170c973e0>
wp_unk_10                = -1
wp_unk_18                = -1
wp_unk_1c                = -1
unk_v47_1                = -1
warmist commented 4 years ago

IIRC this is a "magic number" that means this population is too numerous to count. Seeing the type/race/plant decoded might give more info. Usually the vermin populations are not counted.

tsurezuregusa commented 4 years ago

I see.

{"ALBATROSS_MAN"=>"albatross man"}
{"ALPACA"=>"alpaca"}
{"ANT"=>"ant"}
{"BARK_SCORPION"=>"bark scorpion"}
{"BEETLE"=>"beetle"}
{"BEETLE_MAN"=>"beetle man"}
{"BIRD_FALCON_PEREGRINE"=>"peregrine falcon"}
{"BIRD_GOOSE"=>"goose"}
{"BIRD_GRACKLE"=>"grackle"}
{"BIRD_LOON"=>"loon"}
{"BIRD_LORIKEET"=>"lorikeet"}
{"BIRD_LOVEBIRD_PEACH-FACED"=>"peach-faced lovebird"}
{"BIRD_OSTRICH"=>"ostrich"}
{"BIRD_OWL_BARN"=>"barn owl"}
{"BIRD_OWL_GREAT_HORNED"=>"great horned owl"}
{"BIRD_OWL_SNOWY"=>"snowy owl"}
{"BIRD_PEAFOWL_BLUE"=>"blue peafowl"}
{"BUMBLEBEE"=>"bumblebee"}
{"BUTTERFLY_MONARCH"=>"monarch butterfly"}
{"BUTTERFLY_MONARCH_MAN"=>"monarch butterfly man"}
{"CAVY"=>"cavy"}
{"COW"=>"cow"}
{"DAMSELFLY"=>"damselfly"}
{"DAMSELFLY_MAN"=>"damselfly man"}
{"DEMON_1"=>"shade specter"}
{"DEMON_14"=>"skink brute"}
{"DEMON_15"=>"clear brute"}
{"DEMON_16"=>"moose brute"}
{"DEMON_17"=>"gray brute"}
{"DEMON_2"=>"ghost of snow"}
{"DEMON_20"=>"titmouse demon"}
{"DEMON_21"=>"tick fiend"}
{"DEMON_22"=>"puce demon"}
{"DEMON_23"=>"kinglet brute"}
{"DEMON_24"=>"emerald monster"}
{"DEMON_27"=>"boiling ghost"}
{"DEMON_28"=>"demon of aluminum"}
{"DEMON_3"=>"shadow haunt"}
{"DEMON_5"=>"boiling haunt"}
{"DEMON_6"=>"brine fiend"}
{"DONKEY"=>"donkey"}
{"EQUIPMENT_WAGON"=>"wagon"}
{"FIREFLY"=>"firefly"}
{"FIREFLY_MAN"=>"firefly man"}
{"GIANT_ALBATROSS"=>"giant albatross"}
{"GIANT_BEETLE"=>"giant beetle"}
{"GIANT_BUTTERFLY_MONARCH"=>"giant monarch butterfly"}
{"GIANT_CARDINAL"=>"giant cardinal"}
{"GIANT_CASSOWARY"=>"giant cassowary"}
{"GIANT_DAMSELFLY"=>"giant damselfly"}
{"GIANT_GRASSHOPPER"=>"giant grasshopper"}
{"GIANT_GREAT_HORNED_OWL"=>"giant great horned owl"}
{"GIANT_JUMPING_SPIDER"=>"giant jumping spider"}
{"GIANT_KESTREL"=>"giant kestrel"}
{"GIANT_MANTIS"=>"giant mantis"}
{"GIANT_PARAKEET"=>"giant parakeet"}
{"GIANT_PEACH-FACED_LOVEBIRD"=>"giant peach-faced lovebird"}
{"GIANT_THRIPS"=>"giant thrips"}
{"GRASSHOPPER"=>"grasshopper"}
{"GRASSHOPPER_MAN"=>"grasshopper man"}
{"GREAT_HORNED_OWL_MAN"=>"great horned owl man"}
{"HONEY_BEE"=>"honey bee"}
{"HORSE"=>"horse"}
{"KESTREL_MAN"=>"kestrel man"}
{"LLAMA"=>"llama"}
{"LOON_MAN"=>"loon man"}
{"LOUSE"=>"louse"}
{"MAGPIE_MAN"=>"magpie man"}
{"MANTIS_MAN"=>"mantis man"}
{"MOON_SNAIL_MAN"=>"moon snail man"}
{"MOSQUITO_MAN"=>"mosquito man"}
{"MULE"=>"mule"}
{"OSPREY_MAN"=>"osprey man"}
{"PEACH-FACED_LOVEBIRD_MAN"=>"peach-faced lovebird man"}
{"SHEEP"=>"sheep"}
{"SLUG"=>"slug"}
{"SLUG_MAN"=>"slug man"}
{"SNAIL"=>"snail"}
{"TERMITE"=>"termite"}
{"THRIPS"=>"thrips"}
{"TICK"=>"tick"}
{"TICK_MAN"=>"tick man"}
{"WORM"=>"worm"}
{"YAK"=>"yak"}
quietust commented 4 years ago

Those populations aren't all animals - you have to look at the "type" field to determine whether you should treat it as a Creature (types 0/1/3/4) or a Plant (types 5/6/7).

lethosor commented 4 years ago

Alignment issues are usually more apparent when looking at the hexadecimal representations of numbers, and 10000001 = 0x00989681, so I wouldn't normally think this was an alignment issue. If all values of quantity(2) started with 0x0098 or something similar, or if we were seeing values like 0x00010002, I would suspect that it could be two int16s (or maybe four int8s) instead of an int32. My understanding is that some values of these fields are in a normal (smaller) range, so the field definition is probably correct here.

tsurezuregusa commented 4 years ago

Yes, I should have thought about hex numbers. Sorry for taking your time.

And I forgot to check for type in test code. It is mostly plants.

{"SPELT"=>"spelt"}
{"BARLEY"=>"barley"}
{"OATS"=>"oat"}
{"ALFALFA"=>"alfalfa"}
{"RYE"=>"rye"}
{"QUINOA"=>"quinoa"}
{"KANIWA"=>"kaniwa"}
{"BITTER_VETCH"=>"bitter vetch"}
{"PURPLE_AMARANTH"=>"purple amaranth"}
{"WHITE_MILLET"=>"white millet plant"}
{"FOXTAIL_MILLET"=>"foxtail millet plant"}
{"HEMP"=>"hemp plant"}
{"ASPARAGUS"=>"asparagus"}
{"STRING_BEAN"=>"string bean plant"}
{"BROAD_BEAN"=>"broad bean plant"}
{"CABBAGE"=>"cabbage"}
{"WILD_CARROT"=>"wild carrot plant"}
{"CELERY"=>"celery"}
{"CHICORY"=>"chicory"}
{"GARDEN_CRESS"=>"garden cress"}
{"GARLIC"=>"garlic plant"}
{"LEEK"=>"leek"}
{"LENTIL"=>"lentil plant"}
{"LETTUCE"=>"lettuce"}
{"MUSKMELON"=>"muskmelon vine"}
{"ONION"=>"onion plant"}
{"PARSNIP"=>"parsnip plant"}
{"PEA"=>"pea plant"}
{"POTATO"=>"potato plant"}
{"RADISH"=>"radish plant"}
{"RED_BEAN"=>"red bean vine"}
{"RHUBARB"=>"rhubarb"}
{"SOYBEAN"=>"soybean plant"}
{"SPINACH"=>"spinach"}
{"TURNIP"=>"turnip plant"}
{"LONG_YAM"=>"long yam plant"}
{"GRAPE"=>"grape vine"}
{"CRANBERRY"=>"cranberry vine"}
{"BILBERRY"=>"bilberry bush"}
{"BLUEBERRY"=>"blueberry bush"}
{"BLACKBERRY"=>"blackberry bush"}
{"RASPBERRY"=>"raspberry bush"}
{"MEADOW-GRASS"=>"meadow-grass"}
{"HAIR GRASS"=>"hair grass"}
{"BENTGRASS"=>"bentgrass"}
{"RYEGRASS"=>"ryegrass"}
{"FESCUE GRASS"=>"fescue grass"}
{"REEDGRASS"=>"reedgrass"}
{"KNOTGRASS"=>"knotgrass"}
{"GRAMA"=>"grama"}
{"DROPSEED GRASS"=>"dropseed grass"}
{"NEEDLE GRASS"=>"needle grass"}
{"ALMOND"=>"almond tree"}
{"APPLE"=>"apple tree"}
{"APRICOT"=>"apricot tree"}
{"BAYBERRY"=>"bayberry tree"}
{"CHERRY"=>"cherry tree"}
{"GINKGO"=>"ginkgo tree"}
{"HAZEL"=>"hazel tree"}
{"PEACH"=>"peach tree"}
{"PEAR"=>"pear tree"}
{"PECAN"=>"pecan tree"}
{"PERSIMMON"=>"persimmon tree"}
{"SAND_PEAR"=>"sand pear tree"}
{"WALNUT"=>"walnut tree"}
{"BERRIES_PRICKLE"=>"prickle berry"}
{"BERRIES_STRAW"=>"strawberry plant"}
{"GRASS_LONGLAND"=>"Longland grass"}
{"WEED_RAT"=>"rat weed"}
{"BERRIES_FISHER"=>"fisher berry"}
{"REED_ROPE"=>"rope reed"}
{"ROOT_HIDE"=>"hide root"}
{"WILLOW"=>"willow"}
{"CHESTNUT"=>"chestnut"}
{"ALDER"=>"alder"}
{"BIRCH"=>"birch"}
{"ASH"=>"ash"}
{"WORM"=>"worm"}
{"TICK"=>"tick"}
{"LOUSE"=>"louse"}
{"THRIPS"=>"thrips"}
{"SLUG"=>"slug"}
{"TERMITE"=>"termite"}
{"SNAIL"=>"snail"}
{"BEETLE"=>"beetle"}
{"ANT"=>"ant"}
{"HONEY_BEE"=>"honey bee"}
{"BUMBLEBEE"=>"bumblebee"}
{"FUNGIWOOD"=>"fungiwood"}
{"TOWER_CAP"=>"tower-cap"}
{"POD_SWEET"=>"sweet pod"}
{"BUSH_QUARRY"=>"quarry bush"}
{"MUSHROOM_HELMET_PLUMP"=>"plump helmet"}
{"GRASS_WHEAT_CAVE"=>"cave wheat"}
{"CAVE MOSS"=>"cave moss"}
{"FLOOR FUNGI"=>"floor fungus"}
{"GOBLIN_CAP"=>"goblin-cap"}
{"TUNNEL_TUBE"=>"tunnel tube"}
{"SPORE_TREE"=>"spore tree"}
{"BLACK_CAP"=>"black-cap"}
{"MUSHROOM_CUP_DIMPLE"=>"dimple cup"}
{"GRASS_TAIL_PIG"=>"pig tail"}
{"NETHER_CAP"=>"nether-cap"}
{"BLOOD_THORN"=>"blood thorn"}
{"DEMON_17"=>"earthworm monster"}
{"DEMON_1"=>"monster of snow"}
{"DEMON_18"=>"leech fiend"}
{"DEMON_15"=>"one-eyed monster"}
{"DEMON_12"=>"skink monster"}
{"DEMON_19"=>"coral monster"}
{"DEMON_22"=>"elephant devil"}
{"ARTICHOKE"=>"artichoke"}
{"BEET"=>"beet plant"}
{"CAPER"=>"caper bush"}
{"BLUE SEDGE"=>"blue sedge"}
{"FIELD SEDGE"=>"field sedge"}
{"PURPLE MOOR GRASS"=>"purple moor grass"}
{"VELVET GRASS"=>"velvet grass"}
{"MEADOWSWEET"=>"meadowsweet"}
{"HERB_VALLEY"=>"valley herb"}
{"DEMON_16"=>"elk monster"}
{"DEMON_5"=>"phantom of snow"}
{"DEMON_3"=>"snow ghost"}
{"DEMON_2"=>"white specter"}
{"DEMON_4"=>"sleet devil"}
{"SAGUARO"=>"saguaro"}
{"BABY TOES SUCCULENT"=>"baby toes succulent"}
{"PEBBLE PLANTS"=>"pebble plant"}
{"DEMON_11"=>"bull brute"}
{"DEMON_20"=>"assassin bug monster"}
{"VINE_WHIP"=>"whip vine"}
{"HIGHWOOD"=>"highwood"}
{"ROOT_MUCK"=>"muck root"}
{"BULB_KOBOLD"=>"kobold bulb"}
{"COMMON REED"=>"common reed"}
{"CATTAIL"=>"cattail"}
{"MARSH THISTLE"=>"marsh thistle"}
{"SAWGRASS"=>"sawgrass"}