Skip to content

Instantly share code, notes, and snippets.

View ennorehling's full-sized avatar

Enno Rehling ennorehling

View GitHub Profile
@ennorehling
ennorehling / valgrind_strtod.c
Created June 9, 2015 05:51
This program makes valgrind complain about an invalid read in strtod
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <gnu/libc-version.h>
int main(void) {
char *endp;
char *str = strdup("id");
double ld;
puts (gnu_get_libc_version ());
### Keybase proof
I hereby claim:
* I am ennorehling on github.
* I am ennorehling (https://keybase.io/ennorehling) on keybase.
* I have a public key whose fingerprint is 896F F20D 7F47 3AC0 2997 FC24 2270 9561 3871 3193
To claim this, I am signing this object:
local function curse(r)
if not r:get_flag("rain") then
msg = message.create("rain")
msg:set_region("region", r)
msg:send_region(r)
r:set_flag("rain")
end
end
function rain.update(id)
-- ./eressea -v0 -t 1001 shipfix.lua
require 'config'
infos = {}
for line in io.lines("ships.txt") do
id = string.match(line, "^(%d+)%s*")
info = line:sub(id:len()+2)
infos[tonumber(id)] = info
end
-- ./eressea -v0 -t 858 shipinfo.lua > ships.txt
require 'config'
eressea.read_game(get_turn() .. ".dat")
for r in regions() do
for s in r.ships do
if s.info:len()>120 then
print(s.id, s.info)
end
end

TODO

disabled tests

wegen reduce_skill:

  • test_exp_drain
  • test_foolpotion
  • test_mistletoe_okay
@ennorehling
ennorehling / cppcheck.txt
Created February 25, 2018 19:11
2018-02-25 cppcheck results for Eressea 3.15
[src/creport.c:1090]: (warning) %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'.
[src/creport.c:1519]: (warning) %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'.
[src/gmtool.c:83]: (information) Skipping configuration 'STDIO_CP' since the value of 'STDIO_CP' is unknown. Use -D if you want to check it. You can use -U to skip it explicitly.
[src/kernel/order.c:137]: (style) The scope of the variable 'obuf' can be reduced.
[src/kernel/save.c:1191] -> [src/kernel/save.c:1192]: (style) Variable 'sz' is reassigned a value before the old one has been used.
[src/kernel/save.c:278]: (style) The scope of the variable 'f' can be reduced.
[src/kernel/save.c:904]: (style) The scope of the variable 'line' can be reduced.
[src/kernel/save.c:1397]: (style) The scope of the variable 'bp' can be reduced.
[src/kernel/save.c:1398]: (style) The scope of the variable 'shp' can be reduced.
[src/kernel/terrain.c:74]: (style) The scope of the variable 'n' can be re
@ennorehling
ennorehling / kodeklubben.py
Last active May 25, 2018 05:28
kodeklubben er kult
from turtle import *
def plot(str, w):
i = 0
while (i+2 < len(str)):
p = str[i]
a = (ord(str[i+1]) - ord('0'))
d = (ord(str[i+2]) - ord('0'))
i = i + 3
if p == 'c':
@ennorehling
ennorehling / bug2470.lua
Created July 30, 2018 18:17
Fix peasants in new player area
require 'config'
filename = get_turn() .. '.dat'
eressea.read_game(filename)
maxps = {
['plain'] = 10000,
['mountain'] = 1000,
['glacier'] = 100,
['highland'] = 4000,
@ennorehling
ennorehling / convert.sh
Created December 17, 2018 11:07
Source encoding fixer
#!/bin/sh
while [ ! -z $1 ] ; do
tmpfile=$(mktemp eressea.XXX)
iconv -f latin1 -t utf-8 < $1 | \
perl -pe 's/ß/ss/; s/ä/ae/; s/ü/ue/; s/ö/oe/;' \
> $tmpfile && \mv $tmpfile $1
shift 1
done