Skip to content

Instantly share code, notes, and snippets.

View warmist's full-sized avatar
💭
Making a game or sth

Warmist warmist

💭
Making a game or sth
View GitHub Profile
@warmist
warmist / thign.hpp
Created August 7, 2018 10:11
threading experiment
#include <mutex>
template<typename T,typename M=std::mutex>
struct protected_variable
{
T data;
M data_mutex;
template <typename F>
void with(F f){
std::lock_guard<M> lock(data_mutex);
@warmist
warmist / lt_markdeep.js
Last active April 25, 2018 11:28
Lt language for markdeep
var LITHUANIAN = {
keyword: {
table: 'lentelė',
figure: 'paveikslėlis',
listing: 'sąrašas',
diagram: 'diagrama',
contents: 'Turinys',
sec: 'sk',
section: 'skyrius',
Log file created at: 2017/09/01 16:47:21
Running on machine: DESKTOP-P4285VI
Log line format: [IWEF]mmdd hh:mm:ss.uuuuuu threadid file:line] msg
@ 00007FFCFEC97799 principia__RenderedVesselTrajectory [0x00007FFCFEC97798+218356]
@ 00007FFCFEC0735F principia__FlightPlanRemoveLast [0x00007FFCFEC0735E+571018]
@ 00007FFCFEC254EB principia__FlightPlanRemoveLast [0x00007FFCFEC254EA+694294]
@ 00007FFCFEB0AEE8 principia__IteratorAtEnd [0x00007FFCFEB0AEE7+20463]
@ 00007FFCFEB2C620 principia__FreeVesselsAndPartsAndCollectPileUps [0x00007FFCFEB2C61F+107]
@ 000000002CFA1A4C (No symbol) [0x000000002CFA1A4B]
F0901 16:47:21.103809 6832 vessel.cpp:127] Check failed: !parts_.empty()
@warmist
warmist / my_lib.hpp
Last active August 2, 2017 13:07
Misc cpp functions
template<typename T,long N>
constexpr long countof(T(&)[N]){return N;}
//TODO: add this -http://stackoverflow.com/a/24881903
//TODO: file embedding lib
/*
void GetResourceAsString(int nResourceID, CStringA &strResourceString)
{
HRSRC hResource = FindResource(NULL, MAKEINTRESOURCE(nResourceID), L"DATA");
HGLOBAL hResHandle = LoadResource(NULL, hResource);
#ifndef VIRIDIS_HPP_INCLUDED
#define VIRIDIS_HPP_INCLUDED
void map_to_viridis(float v, uint8_t& r, uint8_t& g, uint8_t& b);
#endif
#ifdef VIRIDIS_IMPLEMENTATION
const double viridis_map[] = {
0.26700401, 0.00487433, 0.32941519,
0.26851048, 0.00960483, 0.33542652,
@warmist
warmist / imbue.lua
Last active December 15, 2016 16:23
imbue
function set_histfig_material(item,base_material,figure_id)
local figure_base=219
local creature_base=19
item:setMaterial(figure_base+base_material-creature_base)
item:setMaterialIndex(figure_id)
end
function reaction_imbue(reaction,reaction_product,unit,input_items,input_reagents,output_items,call_native)
--printall(input_items[1])
local mat_source=input_items[1]
local mat=mat_source:getActualMaterial()
@warmist
warmist / http.lua
Last active December 13, 2016 18:28
Work in progress
-- this requires a plugin that draws the map: https://github.com/warmist/dfhack/tree/twbt_experiments
--[[
Ideas for future:
microtransactions (for rooms and stuff :D) jkjk
assignment to locations (e.g. performance etc)
see if idle location can be used for direct dwarf control
more info about dwarf
possesions (with a way to add/remove them)
rooms
artifacts
local args={...}
flags=flags or {}
local ann=df.global.announcements.flags
if args[1]=='-s' then
print('saving')
for k,v in pairs(ann) do
flags[k]=copyall(v)
end
elseif args[1]=='-r' then
print('restoring')
#pragma once
//source: https://github.com/WG21-SG14/SG14/blob/master/SG14/inplace_function.h
#include <type_traits>
#include <functional>
namespace stdext
{
constexpr size_t InplaceFunctionDefaultCapacity = 32;
constexpr size_t InplaceFunctionDefaultAlignment = 16;
local args={...}
local site
for k,v in ipairs(df.global.world.world_data.sites) do
if dfhack.TranslateName(v.name)==args[1] then
site=v
end
end
if site==nil then