Skip to content

Instantly share code, notes, and snippets.

View ennorehling's full-sized avatar

Enno Rehling ennorehling

View GitHub Profile
function test_bug_2605()
local r0 = region.create(0, 0, "plain")
local r1 = region.create(1, 0, "plain")
local r2 = region.create(2, 0, "plain")
local r3 = region.create(3, 0, "plain")
local f = faction.create("human")
-- 1. two walkers, each with two horses and a cart:
local u1 = unit.create(f, r0, 2)
u1:add_item("horse", 2)
u1:add_item("cart", 1)
function test_rider_leads_horses()
local r0 = region.create(0, 0, "plain")
local r1 = region.create(1, 0, "plain")
local r2 = region.create(2, 0, "plain")
local r3 = region.create(3, 0, "plain")
local f = faction.create("human")
-- lead 1 extra horse per level while riding:
local u1 = unit.create(f, r0, 1)
u1:set_skill("riding", 1)
u1:add_item("horse", 2)
@ennorehling
ennorehling / crsample.json
Created June 30, 2019 17:25
Sample CR to JSON conversion
{
"charset": "UTF-8",
"locale": "de",
"noskillpoints": 1,
"date": 1509041527,
"Spiel": "Drachensgrab",
"Konfiguration": "Standard",
"Koordinaten": "Hex",
"max_units": 50,
"Basis": 36,
@ennorehling
ennorehling / test.json
Last active February 18, 2019 11:19
CR to JSON result
{
"Basis": 36,
"home": "0 1 2",
"charset": "UTF-8",
"noskillpoints": 1,
"PARTEI": [
{
"id": 1045107,
"locale": "de",
"age": 8
@ennorehling
ennorehling / test.cr
Created February 17, 2019 22:09
CR to JSON demonstration
VERSION 66
36;Basis
0 1 2;home
"UTF-8";charset
1;noskillpoints
PARTEI 1045107
"de";locale
8;age
PARTEI 683844
"de";locale
@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
@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 / 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 / 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

TODO

disabled tests

wegen reduce_skill:

  • test_exp_drain
  • test_foolpotion
  • test_mistletoe_okay