Skip to content

Instantly share code, notes, and snippets.

@dorkster
dorkster / gist:ddd19a0c91400ffd1c31c8ba18df8c1b
Created March 25, 2022 18:20
Flare render priority explanation
(Quoted from Stefan Beller)
The maximum size of a map is 256 tiles in each dimension, because 256 is hardcoded in a few places, such as
the layerdata arrays passed around to renderIsoLayer for example.
The higher the bits are in prio the more important they are.
The first expression (((uint64_t)(tilex + tiley)) << 48) is used to determine on which tile we're standing as this is the top priority for sorting. tilex and tiley should be both between 0 and 256 as they are just the position of the entity as integer numbers. The sum of them should be in range 0 to 512. How many bits are required to display a number in range 0 to 512? We need 9 bits, because 2^9=512. So the goal is to put this number in range 0 to 512 in the most upper bits of the prio. Assuming we have a number with 64 bits, the bits are at positions 0 to 63. To put the number into the most upper bits we need to shift the number there, by 63 - 9 = 54 bits. 63 as that is the highest bit position available and 9 because of the number range.
Now for
@dorkster
dorkster / PlatformLinux.cpp
Created March 13, 2018 04:03
MacOS app path test
/*
Copyright © 2016 Justin Jacobs
This file is part of FLARE.
FLARE is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation,
either version 3 of the License, or (at your option) any later version.
FLARE is distributed in the hope that it will be useful, but WITHOUT ANY
#!/bin/bash
# Usage: run this script in the root of a Flare mod to update all keys pertaining to primary stats.
TITLE_STATS_IN=("physment" "physoff" "physdef" "mentoff" "mentdef" "offdef")
TITLE_STATS_OUT=("physical,mental" "physical,offense" "physical,defense" "mental,offense" "mental,defense" "offense,defense")
if [ -e "engine/titles.txt" ]; then
for i in "${!TITLE_STATS_IN[@]}"; do
sed -i -e "s/${TITLE_STATS_IN[i]}/${TITLE_STATS_OUT[i]}/g" "engine/titles.txt"
@dorkster
dorkster / create_overlay.sh
Created July 31, 2016 23:38
Script to visualize tile IDs in Flare tileset definitions
#!/bin/bash
# This script reads a Flare tileset definition and creates a version of the tileset image with tile ID overlays
# it should be run from the same directory that contains the tileset definition (e.g. mods/fantasycore/tilesetdefs/)
# Usage: ./create_overlay.sh tileset_dungeon.txt
if [ ! -f "$1" ]; then
echo "Error: $1 is not a valid file"
exit
fi
Thread 1 "FlareFramework" received signal SIGFPE, Arithmetic exception.
0x00000000004397e6 in IconWidget::setIconNumber (this=0x158b3d0, icon=0)
at iconwidget.cpp:19
19 selection = QPoint(icon % iconsInRow, icon / iconsInRow);
(gdb) bt
#0 0x00000000004397e6 in IconWidget::setIconNumber (this=0x158b3d0, icon=0)
at iconwidget.cpp:19
#1 0x0000000000439319 in IconView::setActiveIcon (this=0xcd5df0, icon=0)
at iconview.cpp:47
#2 0x000000000043e074 in IconChooser::setActiveIcon (this=0xcd5690, value=0)
#!/bin/bash
STATS=("hp" "hp_regen" "mp" "mp_regen" "accuracy" "avoidance" "dmg_melee_min" "dmg_melee_max" "dmg_ranged_min" "dmg_ranged_max" "dmg_ment_min" "dmg_ment_max" "absorb_min" "absorb_max" "crit" "xp_gain" "currency_find" "item_find" "stealth" "poise" "reflect_chance" "return_damage" "hp_percent" "mp_percent")
function fn_stat_convert {
FILENAME="$1"
for i in ${STATS[@]}; do
sed -i \
-e "s/^${i}=/stat=${i},/g" \
#!/usr/bin/env python
# Usage:
# Run ./update_map_objects.py from base directory containing mods/ and tiled/
# OR
# Run ./update_map_objects.py FILENAME to update a single TXT or TMX file
import os
import sys
import xml.etree.ElementTree as etree
@dorkster
dorkster / gist:c7a8a13cebbf9104c8e5
Created February 27, 2016 19:53
Unpacked zombie.txt
image=images/enemies/zombie.png
render_size=128,128
render_offset=64,96
[stance]
position=0
frames=4
duration=533ms
type=back_forth
From 88bc00ab9ea6fd6714462e3567416fa014aa100e Mon Sep 17 00:00:00 2001
From: Justin Jacobs <jajdorkster@gmail.com>
Date: Tue, 3 Nov 2015 19:40:05 -0500
Subject: [PATCH] Attempt to fix shaders on Android
- Move from shader version 110 to 100
- Add logging for failed shader compilation
---
mods/default/shaders/fragment.glsl | 13 +++++++++----
mods/default/shaders/fragment_p.glsl | 7 ++++++-
Executing tasks: [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:compileDebugSources, :app:compileDebugAndroidTestSources]
Configuration on demand is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE