Skip to content

Instantly share code, notes, and snippets.

View pronvit's full-sized avatar

Vitaly Pronkin pronvit

View GitHub Profile
#!/usr/bin/perl
# this script generates C headers from df-structures codegen.out.xml
# input is 1st argument or 'codegen/codegen.out.xml'
# default is generating IDA-compatible headers
# to generate full C headers, use
# perl codegen --stdc
typedef void* (*MALLOC)(size_t);
MALLOC old_malloc;
typedef void (*FREE)(intptr_t);
FREE old_free;
void* new_malloc(size_t s)
{
void *addr = old_malloc(s+32);
function find_race(name)
name = name:lower()
for i,v in ipairs(df.global.world.raws.creatures.all) do
if v.creature_id:lower() == name:lower() then
return i
end
end
end
local gui = require 'gui'
local dialog = require 'gui.dialogs'
local widgets = require 'gui.widgets'
local guiScript = require 'gui.script'
local utils = require 'utils'
function show_description(type, id)
local unit = df.unit:new()
local scr = df.viewscreen_unitlistst:new()
@pronvit
pronvit / biomes.lua
Created November 15, 2016 07:38
biome stuff
local biome_region_offsets = { {-1,-1}, {0,-1}, {1,-1}, {-1,0}, {0,0}, {1,0}, {-1,1}, {0,1}, {1,1} }
local biome_offset_idx = block.region_offset[block.designation[x%16][y%16].biome]
local geolayer_idx = block.designation[x%16][y%16].geolayer_index
local offset = biome_region_offsets[biome_offset_idx+1]
local rpos = { bit32.rshift(df.global.world.map.region_x,4) + offset[1], bit32.rshift(df.global.world.map.region_y,4) + offset[2] }
local rbio = dfhack.maps.getRegionBiome(table.unpack(rpos))
local geobiome = df.world_geo_biome.find(rbio.geo_index)
local layer = geobiome.layers[geolayer_idx]
ms = require 'memscan'
cdata = ms.get_cdata_segment()
data = ms.get_data_segment()
function reverseAndReadString(buf, idx)
local s = ''
local min = idx - 200
while idx > min do
local c = buf[idx]
<?xml version='1.0'?>
<data-definition>
<symbol-table name='0.43.04' os-type='darwin'>
<md5-hash value='319ec9286b56bbcf45348c2356a37bd3'/>
.data
<global-address name='cursor'/>
<global-address name='selection_rect'/>
<global-address name='gamemode'/>
@pronvit
pronvit / gist:c20e3577fd2f9683a144
Created August 13, 2014 00:19
Ace editor syntax highlighting for Dwarf Fortress config files
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var DFHighlightRules = function() {
this.$rules = {
"start": [