sqlite db

master
Dominik Madarász 2024-05-29 10:11:37 +02:00
parent e2e6ef9185
commit a9ea1e9335
30 changed files with 271361 additions and 6371 deletions

2
.gitignore vendored
View File

@ -20,5 +20,7 @@ GTAGS
pkg
pkg.zip
eco2d.zip
eco2d.db
eco2d.sublime-workspace
.cache

View File

@ -0,0 +1,28 @@
-- typedef enum {
-- BLOCK_FLAG_COLLISION = (1 << 1),
-- BLOCK_FLAG_HAZARD = (1 << 2),
-- BLOCK_FLAG_ESSENTIAL = (1 << 3),
-- BLOCK_FLAG_DESTROY_ON_COLLISION = (1 << 4),
-- BLOCK_FLAG_ENTITY = (1 << 5),
-- } block_flags;
INSERT INTO blocks (kind, flags, drag, friction, bounce, velx, vely) VALUES
(asset('EMPTY'), NULL, NULL, NULL, NULL, NULL, NULL),
(asset('GROUND'), NULL, 1.0, 1.0, NULL, NULL, NULL),
(asset('DIRT'), NULL, 2.1, 1.0, NULL, NULL, NULL),
(asset('WALL'), (1<<1), 1.0, 1.0, 1.0, NULL, NULL),
(asset('HILL'), (1<<1), 1.0, 1.0, NULL, NULL, NULL),
(asset('HILL_SNOW'), (1<<1), 1.0, 1.0, NULL, NULL, NULL),
(asset('WATER'), 0, 0.11, 1.0, NULL, NULL, NULL),
(asset('LAVA'), (1<<2), 6.2, 4.0, NULL, NULL, NULL),
(asset('FENCE'), (1<<1), 1.0, 1.0, 1.0, NULL, NULL),
(asset('WOOD'), (1<<1), 1.0, 1.0, 0.0, NULL, NULL),
(asset('TREE'), (1<<1)|(1<<4), 1.0, 1.0, 0.0, NULL, NULL),
(asset('CHEST'), (1<<5), NULL, NULL, NULL, NULL, NULL),
(asset('FURNACE'), (1<<5), NULL, NULL, NULL, NULL, NULL),
(asset('TEST_TALL'), (1<<1), NULL, NULL, NULL, NULL, NULL),
(asset('BELT_LEFT'), NULL, 1.0, 1.0, NULL, -150.0, NULL),
(asset('BELT_RIGHT'), NULL, 1.0, 1.0, NULL, 150.0, NULL),
(asset('BELT_UP'), NULL, 1.0, 1.0, NULL, NULL, -150.0),
(asset('BELT_DOWN'), NULL, 1.0, 1.0, NULL, NULL, 150.0);

View File

@ -0,0 +1,44 @@
-- typedef enum {
-- // NOTE(zaklaus): hardcoded fields for placement ops
-- UKIND_DELETE,
-- UKIND_PLACE,
-- UKIND_PLACE_ITEM,
-- UKIND_PLACE_ITEM_DATA,
-- UKIND_END_PLACE,
--
-- // NOTE(zaklaus): the rest of possible actions
-- UKIND_HOLD,
-- UKIND_PROXY,
-- } item_usage;
--
-- typedef enum {
-- UDATA_NONE,
-- UDATA_ENERGY_SOURCE,
-- } item_attachment;
INSERT INTO items (kind, usage, attachment, max_quantity, place_kind, directional, proxy_id, place_item_id, producer, energy_level, blueprint_w, blueprint_h, blueprint_plan) VALUES
(0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(asset('FENCE'), 5, 0, 64, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(asset('COAL'), 5, 1, 64, NULL, NULL, NULL, NULL, asset('FURNACE'), 15.0, NULL, NULL, NULL),
(asset('WOOD'), 1, 0, 64, asset('WOOD'), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(asset('TREE'), 1, 0, 64, asset('TREE'), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(asset('TEST_TALL'), 1, 0, 64, asset('TEST_TALL'), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(asset('BELT'), 1, 0, 999, asset('BELT'), 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(asset('BELT_LEFT'), 6, 0, NULL, NULL, NULL, asset('BELT'), NULL, NULL, NULL, NULL, NULL, NULL),
(asset('BELT_RIGHT'), 6, 0, NULL, NULL, NULL, asset('BELT'), NULL, NULL, NULL, NULL, NULL, NULL),
(asset('BELT_UP'), 6, 0, NULL, NULL, NULL, asset('BELT'), NULL, NULL, NULL, NULL, NULL, NULL),
(asset('BELT_DOWN'), 6, 0, NULL, NULL, NULL, asset('BELT'), NULL, NULL, NULL, NULL, NULL, NULL),
(asset('CHEST'), 2, 0, 32, NULL, NULL, NULL, asset('CHEST'), NULL, NULL, NULL, NULL, NULL),
(asset('CRAFTBENCH'), 2, 0, 32, NULL, NULL, NULL, asset('CRAFTBENCH'), NULL, NULL, NULL, NULL, NULL),
(asset('FURNACE'), 2, 0, 32, NULL, NULL, NULL, asset('FURNACE'), NULL, NULL, NULL, NULL, NULL),
(asset('SPLITTER'), 2, 0, 32, NULL, NULL, NULL, asset('SPLITTER'), NULL, NULL, NULL, NULL, NULL),
(asset('ASSEMBLER'), 2, 0, 32, NULL, NULL, NULL, asset('ASSEMBLER'), NULL, NULL, NULL, NULL, NULL),
(asset('CREATURE'), 2, 0, 32, NULL, NULL, NULL, asset('CREATURE'), NULL, NULL, NULL, NULL, NULL),
(asset('IRON_ORE'), 5, 0, 64, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(asset('IRON_INGOT'), 5, 0, 64, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(asset('IRON_PLATES'), 5, 0, 64, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(asset('SCREWS'), 5, 0, 64, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(asset('LOG'), 5, 0, 64, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(asset('PLANK'), 5, 0, 64, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(asset('CREATURE_FOOD'), 5, 0, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
-- (asset('BLUEPRINT_DEMO_HOUSE'), 3, 0, 1, NULL, NULL, NULL, asset('BLUEPRINT'), NULL, NULL, 4, 4, ''),

View File

@ -0,0 +1,18 @@
INSERT INTO recipes (product, product_qty, process_ticks, producer) VALUES
(asset('IRON_PLATES'), 4, 20, asset('FURNACE')),
(asset('SCREWS'), 8, 40, asset('CRAFTBENCH')),
(asset('BELT'), 1, 120, asset('ASSEMBLER'));
INSERT INTO reagents (asset_id, qty) VALUES
(asset('IRON_ORE'), 1),
(asset('IRON_PLATES'), 1),
(asset('FENCE'), 1),
(asset('SCREWS'), 4),
(asset('IRON_PLATES'), 2);
INSERT INTO recipe_reagents (recipe_id, reagent_id) VALUES
(1, 1),
(2, 2),
(3, 3),
(3, 4),
(3, 5);

View File

@ -0,0 +1,42 @@
INSERT INTO resources (asset, kind) VALUES
(asset('EMPTY'), 0),
(asset('BLANK'), 0),
(asset('BLOCK_FRAME'), 0),
(asset('BUILDMODE_HIGHLIGHT'), 0),
(asset('COAL'), 0),
(asset('IRON_ORE'), 0),
(asset('IRON_INGOT'), 0),
(asset('IRON_PLATES'), 0),
(asset('SCREWS'), 0),
(asset('LOG'), 0),
(asset('PLANK'), 0),
(asset('CHEST'), 0),
(asset('CREATURE'), 0),
(asset('CREATURE_FOOD'), 0),
(asset('FURNACE'), 0),
(asset('SPLITTER'), 0),
(asset('ASSEMBLER'), 0),
(asset('CRAFTBENCH'), 0),
(asset('BLUEPRINT'), 0),
(asset('BLUEPRINT_DEMO_HOUSE'), 0),
(asset('MOB'), 0),
(asset('PLAYER'), 0),
(asset('FENCE'), 0),
(asset('DEV'), 0),
(asset('GROUND'), 0),
(asset('DIRT'), 0),
(asset('WATER'), 2),
(asset('LAVA'), 0),
(asset('WALL'), 0),
(asset('HILL'), 0),
(asset('HILL_SNOW'), 0),
(asset('HOLE'), 0),
(asset('WOOD'), 0),
(asset('TEST_TALL'), 0),
(asset('TREE'), 0),
(asset('BELT'), 0),
(asset('BELT_LEFT'), 0),
(asset('BELT_RIGHT'), 0),
(asset('BELT_UP'), 0),
(asset('BELT_DOWN'), 0);

View File

@ -0,0 +1,72 @@
CREATE TABLE assets (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(255) NOT NULL
);
CREATE TABLE resources (
id INTEGER PRIMARY KEY AUTOINCREMENT,
asset INTEGER NOT NULL,
kind INTEGER NOT NULL
);
CREATE TABLE blocks (
id INTEGER PRIMARY KEY AUTOINCREMENT,
kind INTEGER NOT NULL,
flags INTEGER DEFAULT 0,
drag REAL,
friction REAL,
bounce REAL,
velx REAL,
vely REAL,
FOREIGN KEY (kind) REFERENCES assets(id)
);
CREATE TABLE items (
id INTEGER PRIMARY KEY AUTOINCREMENT,
kind INTEGER NOT NULL,
usage INTEGER,
attachment INTEGER,
max_quantity INTEGER,
has_storage BOOLEAN,
place_kind INTEGER,
directional BOOLEAN,
proxy_id INTEGER,
place_item_id INTEGER,
producer INTEGER,
energy_level REAL,
blueprint_w INTEGER,
blueprint_h INTEGER,
blueprint_plan TEXT,
FOREIGN KEY (kind) REFERENCES assets(id)
);
CREATE TABLE reagents (
id INTEGER PRIMARY KEY AUTOINCREMENT,
asset_id INTEGER NOT NULL,
qty INTEGER NOT NULL,
FOREIGN KEY (asset_id) REFERENCES assets(id)
);
CREATE TABLE recipes (
id INTEGER PRIMARY KEY AUTOINCREMENT,
product INTEGER NOT NULL,
product_qty INTEGER NOT NULL,
process_ticks INTEGER NOT NULL,
producer INTEGER NOT NULL,
FOREIGN KEY (product) REFERENCES assets(id),
FOREIGN KEY (producer) REFERENCES assets(id)
);
CREATE TABLE recipe_reagents (
id INTEGER PRIMARY KEY AUTOINCREMENT,
recipe_id INTEGER NOT NULL,
reagent_id INTEGER NOT NULL,
FOREIGN KEY (recipe_id) REFERENCES recipes(id),
FOREIGN KEY (reagent_id) REFERENCES reagents(id)
);

View File

@ -9,6 +9,7 @@ add_library(eco2d-foundation STATIC
src/platform/profiler.c
src/platform/input.c
src/models/database.c
src/models/assets.c
src/models/components.c
src/models/items.c

View File

@ -3,6 +3,7 @@
#include "platform/platform.h"
#include "world/world.h"
#include "pkt/packet.h"
#include "models/database.h"
#include "platform/signal_handling.h"
#include "net/network.h"
#include "models/entity.h"
@ -137,6 +138,8 @@ void game_init(const char *ip, uint16_t port, game_kind play_mode, uint32_t num_
game_mode = play_mode;
game_should_close = false;
db_init();
#ifndef _DEBUG
const char *host_ip = "lab.zakto.pw";
#else
@ -191,6 +194,7 @@ int8_t game_is_networked() {
}
void game_shutdown() {
db_shutdown();
if (game_mode == GAMEKIND_CLIENT) {
network_client_disconnect();
@ -213,7 +217,6 @@ void game_shutdown() {
//platform_shutdown();
UnloadNuklear(game_ui);
}
}
uint8_t game_is_running() {

View File

@ -1,57 +0,0 @@
#include "models/assets.h"
#define ASSET_ENTRY(asset, asset_kind)\
{\
.id = asset,\
.kind = asset_kind,\
}
#define ASSET_SND(asset) ASSET_ENTRY(asset, AKIND_SOUND)
#define ASSET_TEX(asset) ASSET_ENTRY(asset, AKIND_TEXTURE)
#define ASSET_ANI(asset) ASSET_ENTRY(asset, AKIND_ANIM)
static asset assets[] = {
ASSET_TEX(ASSET_EMPTY),
ASSET_TEX(ASSET_BLANK),
ASSET_TEX(ASSET_BLOCK_FRAME),
ASSET_TEX(ASSET_BUILDMODE_HIGHLIGHT),
ASSET_TEX(ASSET_COAL),
ASSET_TEX(ASSET_IRON_ORE),
ASSET_TEX(ASSET_IRON_INGOT),
ASSET_TEX(ASSET_IRON_PLATES),
ASSET_TEX(ASSET_SCREWS),
ASSET_TEX(ASSET_LOG),
ASSET_TEX(ASSET_PLANK),
ASSET_TEX(ASSET_CHEST),
ASSET_TEX(ASSET_CREATURE),
ASSET_TEX(ASSET_CREATURE_FOOD),
ASSET_TEX(ASSET_FURNACE),
ASSET_TEX(ASSET_SPLITTER),
ASSET_TEX(ASSET_ASSEMBLER),
ASSET_TEX(ASSET_CRAFTBENCH),
ASSET_TEX(ASSET_BLUEPRINT),
ASSET_TEX(ASSET_BLUEPRINT_DEMO_HOUSE),
ASSET_TEX(ASSET_MOB),
ASSET_TEX(ASSET_PLAYER),
// NOTE(zaklaus): blocks
ASSET_TEX(ASSET_FENCE),
ASSET_TEX(ASSET_DEV),
ASSET_TEX(ASSET_GROUND),
ASSET_TEX(ASSET_DIRT),
ASSET_ANI(ASSET_WATER),
ASSET_TEX(ASSET_LAVA),
ASSET_TEX(ASSET_WALL),
ASSET_TEX(ASSET_HILL),
ASSET_TEX(ASSET_HILL_SNOW),
ASSET_TEX(ASSET_HOLE),
ASSET_TEX(ASSET_WOOD),
ASSET_TEX(ASSET_TEST_TALL),
ASSET_TEX(ASSET_TREE),
ASSET_TEX(ASSET_BELT),
ASSET_TEX(ASSET_BELT_LEFT),
ASSET_TEX(ASSET_BELT_RIGHT),
ASSET_TEX(ASSET_BELT_UP),
ASSET_TEX(ASSET_BELT_DOWN),
};

View File

@ -1,30 +0,0 @@
#include "world/blocks.h"
#define BLOCK(a, f, s, ...)\
{\
.kind = a, .flags = f, .symbol = s, __VA_ARGS__\
}
static block blocks[] = {
BLOCK(ASSET_EMPTY, 0, 'E'),
BLOCK(ASSET_GROUND, 0, '.', .drag = 1.0f, .friction = 1.0f),
BLOCK(ASSET_DIRT, 0, ',', .drag = 2.1f , .friction = 1.0f),
BLOCK(ASSET_WALL, BLOCK_FLAG_COLLISION, '#', .drag = 1.0f , .friction = 1.0f, .bounce = 1.0f),
BLOCK(ASSET_HILL, BLOCK_FLAG_COLLISION, '^', .drag = 1.0f , .friction = 1.0f),
BLOCK(ASSET_HILL_SNOW, BLOCK_FLAG_COLLISION, '*', .drag = 1.0f , .friction = 1.0f),
BLOCK(ASSET_WATER, 0, '~', .drag = 0.11f , .friction = 1.0f),
BLOCK(ASSET_LAVA, BLOCK_FLAG_HAZARD, '!', .drag = 6.2f , .friction = 4.0f),
BLOCK(ASSET_FENCE, BLOCK_FLAG_COLLISION, '[', .drag = 1.0f , .friction = 1.0f, .bounce = 1.0f),
BLOCK(ASSET_WOOD, BLOCK_FLAG_COLLISION, ']', .drag = 1.0f , .friction = 1.0f, .bounce = 0.0f),
BLOCK(ASSET_TREE, BLOCK_FLAG_COLLISION|BLOCK_FLAG_DESTROY_ON_COLLISION, '@', .drag = 1.0f , .friction = 1.0f, .bounce = 0.0f),
BLOCK(ASSET_CHEST, BLOCK_FLAG_ENTITY, 'C'),
BLOCK(ASSET_FURNACE, BLOCK_FLAG_ENTITY, 'F'),
BLOCK(ASSET_TEST_TALL, BLOCK_FLAG_COLLISION, '.'),
BLOCK(ASSET_BELT_LEFT, 0, '@', .drag = 1.0f , .friction = 1.0f, .velx = -150.0f),
BLOCK(ASSET_BELT_RIGHT, 0, '@', .drag = 1.0f , .friction = 1.0f, .velx = 150.0f),
BLOCK(ASSET_BELT_UP, 0, '@', .drag = 1.0f , .friction = 1.0f, .vely = -150.0f),
BLOCK(ASSET_BELT_DOWN, 0, '@', .drag = 1.0f , .friction = 1.0f, .vely = 150.0f),
};
ZPL_STATIC_ASSERT(sizeof(blocks)/sizeof(block) < ZPL_U16_MAX, "too many registered blocks! (max. 65536)");

View File

@ -1,30 +0,0 @@
#include "models/crafting.h"
#define R(id1,qty1)\
{\
.id = id1,\
.qty = qty1\
}
#define RECIPE(id,prod,qty,ticks,...)\
{\
.product = id,\
.product_qty = qty,\
.process_ticks = ticks,\
.producer = prod,\
.reagents = (reagent[]){\
__VA_ARGS__\
}\
}
static recipe recipes[] = {
// NOTE(zaklaus): Belt
RECIPE(ASSET_IRON_PLATES, ASSET_FURNACE, 4, 20, R(ASSET_IRON_ORE, 1), {0}),
RECIPE(ASSET_SCREWS, ASSET_CRAFTBENCH, 8, 40, R(ASSET_IRON_PLATES, 1), {0}),
RECIPE(ASSET_BELT, ASSET_ASSEMBLER, 1,120, R(ASSET_FENCE, 1), R(ASSET_SCREWS, 4), R(ASSET_IRON_PLATES, 2), {0}),
};
#define MAX_RECIPES (sizeof(recipes)/sizeof(recipes[0]))
#undef R
#undef RECIPE

View File

@ -1,40 +0,0 @@
#include "models/items.h"
#include "world/entity_view.h"
#include "items_list_helpers.h"
static item_desc items[] = {
{ .kind = 0, .max_quantity = 0, },
ITEM_HOLD(ASSET_FENCE, 64),
ITEM_ENERGY(ASSET_COAL, ASSET_FURNACE, 64, 15.0f),
ITEM_SELF(ASSET_WOOD, 64),
ITEM_SELF(ASSET_TREE, 64),
ITEM_SELF(ASSET_TEST_TALL, 64),
// ITEM_BLUEPRINT(ASSET_BLUEPRINT, 1, 4, 4, "]]]]]CF] ]]]]]"),
ITEM_BLUEPRINT_PROXY(ASSET_BLUEPRINT_DEMO_HOUSE, ASSET_BLUEPRINT, 1, 4, 4,
PROT({ ASSET_WOOD,ASSET_WOOD,ASSET_WOOD,ASSET_WOOD,
ASSET_WOOD,ASSET_FURNACE,ASSET_CHEST,ASSET_WOOD,
ASSET_WOOD,ASSET_EMPTY,ASSET_EMPTY,ASSET_WOOD,
ASSET_WOOD,ASSET_WOOD,ASSET_EMPTY,ASSET_WOOD})),
ITEM_SELF_DIR(ASSET_BELT, 999),
ITEM_PROXY(ASSET_BELT_LEFT, ASSET_BELT),
ITEM_PROXY(ASSET_BELT_RIGHT, ASSET_BELT),
ITEM_PROXY(ASSET_BELT_UP, ASSET_BELT),
ITEM_PROXY(ASSET_BELT_DOWN, ASSET_BELT),
ITEM_ENT(ASSET_CHEST, 32, ASSET_CHEST),
ITEM_ENT(ASSET_CRAFTBENCH, 32, ASSET_CRAFTBENCH),
ITEM_ENT(ASSET_FURNACE, 32, ASSET_FURNACE),
ITEM_ENT(ASSET_SPLITTER, 32, ASSET_SPLITTER),
ITEM_ENT(ASSET_ASSEMBLER, 32, ASSET_ASSEMBLER),
ITEM_ENT(ASSET_CREATURE, 32, ASSET_CREATURE),
ITEM_HOLD(ASSET_IRON_ORE, 64),
ITEM_HOLD(ASSET_IRON_INGOT, 64),
ITEM_HOLD(ASSET_IRON_PLATES, 64),
ITEM_HOLD(ASSET_SCREWS, 64),
ITEM_HOLD(ASSET_LOG, 64),
ITEM_HOLD(ASSET_PLANK, 64),
ITEM_HOLD(ASSET_CREATURE_FOOD, 1),
};

View File

@ -1,122 +0,0 @@
#pragma once
#define ITEM_HOLD(asset, qty, ...)\
{\
.kind = asset,\
.usage = UKIND_HOLD,\
.attachment = UDATA_NONE,\
.max_quantity = qty,\
__VA_ARGS__\
}
#define ITEM_ENERGY(asset, producer_asset, qty, energy_value, ...)\
{\
.kind = asset,\
.usage = UKIND_HOLD,\
.attachment = UDATA_ENERGY_SOURCE,\
.max_quantity = qty,\
.energy_source = {\
.producer = producer_asset,\
.energy_level = energy_value\
},\
__VA_ARGS__\
}
#define ITEM_BLUEPRINT(asset, qty, w_, h_, plan_, ...)\
{\
.kind = asset,\
.usage = UKIND_PLACE_ITEM_DATA,\
.attachment = UDATA_NONE,\
.max_quantity = qty,\
.blueprint = {\
.w = w_,\
.h = h_,\
.plan = (const asset_id[])plan_\
},\
.place_item = {\
.id = asset\
},\
__VA_ARGS__\
}
#define ITEM_BLUEPRINT_PROXY(asset, place_asset, qty, w_, h_, plan_, ...)\
{\
.kind = asset,\
.usage = UKIND_PLACE_ITEM_DATA,\
.attachment = UDATA_NONE,\
.max_quantity = qty,\
.blueprint = {\
.w = w_,\
.h = h_,\
.plan = (const asset_id[])plan_\
},\
.place_item = {\
.id = place_asset\
},\
__VA_ARGS__\
}
#define ITEM_INGREDIENT(asset, qty, _producer, _product, _additional, ...)\
{\
.kind = asset,\
.usage = UKIND_HOLD,\
.attachment = UDATA_INGREDIENT,\
.max_quantity = qty,\
.ingredient = {\
.producer = _producer,\
.product = _product,\
.additional_ingredient = _additional,\
},\
__VA_ARGS__\
}
#define ITEM_BLOCK(asset, qty, build_asset, ...)\
{\
.kind = asset,\
.usage = UKIND_PLACE,\
.attachment = UDATA_NONE,\
.max_quantity = qty,\
.place = {\
.kind = build_asset,\
},\
__VA_ARGS__\
}
#define ITEM_BLOCK_DIR(asset, qty, build_asset, ...)\
{\
.kind = asset,\
.usage = UKIND_PLACE,\
.attachment = UDATA_NONE,\
.max_quantity = qty,\
.place = {\
.kind = build_asset,\
.directional = true,\
},\
__VA_ARGS__\
}
#define ITEM_PROXY(asset, proxy_id, ...)\
{\
.kind = asset,\
.usage = UKIND_PROXY,\
.attachment = UDATA_NONE,\
.proxy = {\
.id = proxy_id,\
},\
__VA_ARGS__\
}
#define ITEM_ENT(asset, qty, eid, ...)\
{\
.kind = asset,\
.usage = UKIND_PLACE_ITEM,\
.attachment = UDATA_NONE,\
.max_quantity = qty,\
.place_item = {\
.id = eid\
},\
__VA_ARGS__\
}
#define ITEM_SELF(asset, qty, ...) ITEM_BLOCK(asset, qty, asset, __VA_ARGS__)
#define ITEM_SELF_DIR(asset, qty, ...) ITEM_BLOCK_DIR(asset, qty, asset, __VA_ARGS__)

View File

@ -1,8 +1,10 @@
#include "models/assets.h"
#include "lists/assets_ids.h"
#include "raylib.h"
#include "gen/texgen.h"
#include "models/database.h"
#define ASSETS_COUNT (sizeof(assets)/sizeof(asset))
//#define ASSETS_COUNT (sizeof(assets)/sizeof(asset))
typedef struct {
asset_id id;
@ -16,7 +18,10 @@ typedef struct {
// NOTE(zaklaus): metadata
} asset;
#include "lists/assets_list.c"
//#include "lists/assets_list.c"
static asset *assets;
#define ASSETS_COUNT (zpl_array_count(assets))
#define ASSET_FRAME_RENDER_MS (1.0/1.0)
#define ASSET_FRAME_SKIP 4
@ -25,6 +30,24 @@ static double assets_frame_next_draw = 0.0;
#include <time.h>
void assets_db_init(void) {
for (uint16_t i=0; i<MAX_ASSETS; i++) {
db_exec(zpl_bprintf("INSERT INTO assets (id, name) VALUES (%d, '%s');", i, asset_names[i]+6));
}
}
void assets_db(void) {
zpl_array_init(assets, zpl_heap());
db_push("SELECT * FROM resources;");
for (size_t i=0, end=db_rows(); i<end; i++) {
asset a={0};
a.id = db_int("asset", i);
a.kind = db_int("kind", i);
zpl_array_append(assets, a);
}
db_pop();
}
int32_t assets_setup(void) {
for (uint32_t i=0; i<ASSETS_COUNT; i++) {
asset *b = &assets[i];

View File

@ -11,6 +11,8 @@ typedef enum {
FORCE_AKIND_UINT8 = UINT8_MAX
} asset_kind;
void assets_db_init(void);
void assets_db(void);
int32_t assets_setup(void);
int32_t assets_frame(void);
void assets_destroy(void);

View File

@ -1,7 +1,36 @@
#include "crafting.h"
#include "models/items.h"
#include "models/database.h"
#include "lists/crafting_list.c"
//#include "lists/crafting_list.c"
static recipe *recipes;
#define MAX_RECIPES (zpl_array_count(recipes))
void craft_db(void) {
zpl_array_init(recipes, zpl_heap());
db_push("SELECT * FROM recipes;");
for (size_t i=0, end=db_rows(); i<end; i++) {
recipe r={0};
r.product = db_int("product", i);
r.product_qty = db_int("product_qty", i);
r.process_ticks = db_int("process_ticks", i);
r.producer = db_int("producer", i);
zpl_array_init(r.reagents, zpl_heap());
db_push(zpl_bprintf("SELECT * FROM recipe_reagents WHERE recipe_id=%d;", i+1));
for (size_t j=0, j_end=db_rows(); j<j_end; j++) {
reagent rea={0};
size_t reagent_id = db_int("reagent_id", j);
db_push(zpl_bprintf("SELECT * FROM reagents WHERE id=%d;", reagent_id));
rea.id = db_int("asset_id", 0);
rea.qty = db_int("qty", 0);
db_pop();
zpl_array_append(r.reagents, rea);
}
db_pop();
zpl_array_append(recipes, r);
}
db_pop();
}
uint32_t craft__find_num_recipes_by_reagent(asset_id producer, asset_id id) {
uint32_t num_recipes=0;

View File

@ -17,6 +17,8 @@ typedef struct {
reagent *reagents;
} recipe;
void craft_db(void);
// NOTE(zaklaus): resolves recipe dependencies and consumes reagents
// to enqueue a production of a new item.
// TODO(zaklaus): "items" is assumed to come from ItemContainer component.

View File

@ -0,0 +1,189 @@
#include "models/database.h"
#include "models/assets.h"
#include "3rd_sqlite3.h"
#include "zpl.h"
#include "world/blocks.h"
#include "models/crafting.h"
#include "models/items.h"
#ifndef ECO2D_DB
#define ECO2D_DB "eco2d.db"
#endif
static sqlite3 *db;
static zpl_array(zpl_csv_object) csv_stack;
static
void sql_asset(sqlite3_context *ctx, int argc, sqlite3_value **argv) {
if (argc == 1) {
const char *name = (const char *)sqlite3_value_text(argv[0]);
if (name) {
sqlite3_result_int(ctx, atoi(db_get(zpl_bprintf("SELECT id FROM assets WHERE name = '%s'", name), false)));
return;
}
}
sqlite3_result_null(ctx);
}
void db_init() {
bool new_db = !zpl_fs_exists(ECO2D_DB);
sqlite3_open(ECO2D_DB, &db);
assert(db && "Failed to open database.");
zpl_array_init(csv_stack, zpl_heap());
sqlite3_create_function(db, "asset", 1, SQLITE_UTF8, NULL, sql_asset, NULL, NULL);
if (new_db) {
zpl_printf("[INFO] Creating new database.\n");
db_exec_file("art/queries/tables.sql");
assets_db_init();
db_exec_file("art/queries/resources.sql");
db_exec_file("art/queries/blocks.sql");
db_exec_file("art/queries/recipes.sql");
db_exec_file("art/queries/items.sql");
}
// initialise models db
assets_db();
blocks_db();
craft_db();
item_db();
}
void db_shutdown() {
sqlite3_close(db);
}
char *db_get(char *query, bool header) {
sqlite3_stmt *stmt;
int rc = sqlite3_prepare_v2(db, query, -1, &stmt, 0);
if (rc) {
zpl_printf("[ERROR] Failed to prepare query: %s\n", sqlite3_errmsg(db));
return 0;
}
zpl_string buf = zpl_string_make(zpl_heap(), "");
bool is_first=header;
int cols = sqlite3_column_count(stmt);
while (sqlite3_step(stmt) == SQLITE_ROW) {
if (is_first) {
is_first = 0;
for (int i = 0; i < cols; i++) {
buf = zpl_string_appendc(buf, (const char *)sqlite3_column_name(stmt, i));
if (i < cols - 1) {
buf = zpl_string_appendc(buf, ",");
}
}
buf = zpl_string_appendc(buf, "\n");
}
for (int i = 0; i < cols; i++) {
const char *val = (const char *)sqlite3_column_text(stmt, i);
if (val == NULL)
val = "\"(null)\"";
buf = zpl_string_appendc(buf, val);
if (i < cols - 1) {
buf = zpl_string_appendc(buf, ",");
}
}
buf = zpl_string_appendc(buf, "\n");
}
sqlite3_finalize(stmt);
#if 0
char *data = zpl_bprintf("%s", buf);
zpl_string_free(buf);
#else //@leak
char *data = (char *)buf;
#endif
return data;
}
char *db_row(char *table, char *name) {
int kind = atoi(db_get(zpl_bprintf("SELECT id FROM assets WHERE name='%s';", name), 0));
return db_get(zpl_bprintf("SELECT * FROM %s WHERE kind='%d';", table, kind), 1);
}
bool db_csv(zpl_csv_object *csv, char *query) {
zpl_zero_item(csv);
char *res = db_get(query, 1);
assert(res);
return zpl_csv_parse(csv, res, zpl_heap(), 1);
}
bool db_row_csv(zpl_csv_object *csv, char *table, char *name) {
zpl_zero_item(csv);
char *res = db_row(table, name);
assert(res);
return zpl_csv_parse(csv, res, zpl_heap(), 1);
}
bool db_push(char *query) {
zpl_csv_object csv;
if (db_csv(&csv, query)) {
return false;
}
zpl_array_append(csv_stack, csv);
return true;
}
bool db_row_push(char *table, char *name) {
zpl_csv_object csv;
if (db_row_csv(&csv, table, name)) {
return false;
}
zpl_array_append(csv_stack, csv);
return true;
}
zpl_adt_node *db_field(char *field, int row) {
zpl_csv_object *csv = db_last();
for (int i = 0; i < zpl_array_count(csv->nodes); i++) {
if (!zpl_strcmp(csv->nodes[i].name, field)) {
return &csv->nodes[i].nodes[row];
}
}
assert(0 && "Field not found");
return NULL;
}
size_t db_rows() {
zpl_csv_object *csv = db_last();
return zpl_array_count(csv->nodes[0].nodes);
}
zpl_csv_object *db_last() {
assert(zpl_array_count(csv_stack) > 0);
return zpl_array_end(csv_stack);
}
void db_pop() {
assert(zpl_array_count(csv_stack) > 0);
zpl_csv_free(zpl_array_end(csv_stack));
zpl_array_pop(csv_stack);
}
bool db_exec_file(const char *sql) {
zpl_file_contents contents = zpl_file_read_contents(zpl_heap(), true, sql);
if (!db_exec(contents.data)) {
assert(0 && "Failed to create tables");
return false;
}
zpl_file_free_contents(&contents);
return true;
}
bool db_exec(const char *query) {
bool ok = !sqlite3_exec(db, query, 0, 0, 0);
if (!ok) {
zpl_printf("[ERROR] Failed to execute query: %s\n", sqlite3_errmsg(db));
}
return ok;
}

View File

@ -0,0 +1,28 @@
#pragma once
#include "platform/system.h"
#include "zpl.h"
void db_init();
void db_shutdown();
// raw query data getters
char *db_get(char *query, bool header);
char *db_row(char *table, char *name);
bool db_csv(zpl_csv_object *csv, char *query);
bool db_row_csv(zpl_csv_object *csv, char *table, char *name);
// csv backed data queries
bool db_push(char *query);
bool db_row_push(char *table, char *name);
zpl_adt_node *db_field(char *field, int row);
size_t db_rows();
#define db_str(fld, row) (db_field(fld, row)->string)
#define db_flt(fld, row) (db_field(fld, row)->type == ZPL_ADT_TYPE_STRING ? 0.0f : db_field(fld, row)->real)
#define db_int(fld, row) (db_field(fld, row)->type == ZPL_ADT_TYPE_STRING ? 0 : db_field(fld, row)->integer)
zpl_csv_object *db_last();
void db_pop();
// sql execution
bool db_exec_file(const char *sql);
bool db_exec(const char *query);

View File

@ -3,13 +3,69 @@
#include "world/entity_view.h"
#include "world/world.h"
#include "world/blocks.h"
#include "models/database.h"
#include "models/components.h"
#include "zpl.h"
#include "lists/items_list.c"
#define ITEMS_COUNT (sizeof(items)/sizeof(item_desc))
//#include "lists/items_list.c"
static item_desc *items;
#define ITEMS_COUNT (zpl_array_count(items))
void item_db(void) {
zpl_array_init(items, zpl_heap());
db_push("SELECT * FROM items;");
for (size_t i = 0, end = db_rows(); i < end; i++) {
item_desc item = {0};
item.kind = db_int("kind", i);
item.usage = db_int("usage", i);
item.attachment = db_int("attachment", i);
item.max_quantity = db_int("max_quantity", i);
item.has_storage = db_int("has_storage", i);
switch (item.usage) {
case UKIND_PLACE:
case UKIND_PLACE_ITEM:
case UKIND_PLACE_ITEM_DATA:
item.place.kind = db_int("place_kind", i);
item.place.directional = db_int("directional", i);
item.place_item.id = db_int("place_item_id", i);
break;
case UKIND_PROXY:
item.proxy.id = db_int("proxy_id", i);
break;
default:
break;
}
switch (item.attachment) {
case UDATA_ENERGY_SOURCE:
item.energy_source.producer = db_int("producer", i);
item.energy_source.energy_level = db_flt("energy_level", i);
break;
default:
break;
}
// Handle blueprint data if present
// if (item.usage == UKIND_PLACE_ITEM_DATA) {
// item.blueprint.w = db_int("blueprint_w", i);
// item.blueprint.h = db_int("blueprint_h", i);
// const char *plan_str = db_str("blueprint_plan", i);
//
// // Convert the plan string to an array of asset_id
// size_t plan_len = strlen(plan_str);
// item.blueprint.plan = malloc(plan_len * sizeof(asset_id));
// for (size_t j = 0; j < plan_len; j++) {
// item.blueprint.plan[j] = plan_str[j]; // Assuming plan_str is a string of asset_id
// }
// }
zpl_array_append(items, item);
}
db_pop();
}
static inline item_id item_resolve_proxy(item_id id) {
ZPL_ASSERT(id < ITEMS_COUNT);

View File

@ -65,6 +65,8 @@ typedef struct {
typedef uint16_t item_id;
void item_db(void);
// NOTE(zaklaus): item drops
void item_show(uint64_t ent, bool show);

View File

@ -8,6 +8,7 @@
#define ZPL_NANO
#define ZPL_ENABLE_MATH
#define ZPL_ENABLE_PARSER
#include "zpl.h"
float get_cached_time(void);

View File

@ -1,13 +1,16 @@
#define ZPL_NANO
#include "models/assets.h"
#include "zpl.h"
#define ZPL_NANO
#include "platform/system.h"
#include "world/world.h"
#include "world/blocks.h"
#include "raylib.h"
#include "gen/texgen.h"
#include "world/world_view.h"
#include "models/database.h"
#include "perlin.h"
#define BLOCKS_COUNT (sizeof(blocks)/sizeof(block))
//#define BLOCKS_COUNT (sizeof(blocks)/sizeof(block))
#define WORLD_TEXTURE_BLOCK_SCALE 0.5f
ZPL_TABLE(static, blocks__chunk_tbl, blocks__chunk_tbl_, RenderTexture2D);
@ -34,7 +37,26 @@ typedef struct {
block_id slot;
} block;
#include "lists/blocks_list.c"
//#include "lists/blocks_list.c"
static block *blocks;
#define BLOCKS_COUNT (zpl_array_count(blocks))
void blocks_db() {
zpl_array_init(blocks, zpl_heap());
db_push("SELECT * FROM blocks;");
for (size_t i=0, end=db_rows(); i<end; i++) {
block blk={0};
blk.kind = db_int("kind", i);
blk.flags = db_int("flags", i);
blk.drag = db_flt("drag", i);
blk.friction = db_flt("friction", i);
blk.bounce = db_flt("bounce", i);
blk.velx = db_flt("velx", i);
blk.vely = db_flt("vely", i);
zpl_array_append(blocks, blk);
}
db_pop();
}
int32_t blocks_setup(void) {
for (block_id i=0; i<BLOCKS_COUNT; i++) {

View File

@ -12,6 +12,7 @@ typedef enum {
typedef uint16_t block_id;
void blocks_db(void);
int32_t blocks_setup(void);
void blocks_destroy(void);

250799
code/vendors/3rd_sqlite3.c vendored 100644

File diff suppressed because it is too large Load Diff

13120
code/vendors/3rd_sqlite3.h vendored 100644

File diff suppressed because it is too large Load Diff

712
code/vendors/3rd_sqlite3ext.h vendored 100644
View File

@ -0,0 +1,712 @@
/*
** 2006 June 7
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
**
** May you do good and not evil.
** May you find forgiveness for yourself and forgive others.
** May you share freely, never taking more than you give.
**
*************************************************************************
** This header file defines the SQLite interface for use by
** shared libraries that want to be imported as extensions into
** an SQLite instance. Shared libraries that intend to be loaded
** as extensions by SQLite should #include this file instead of
** sqlite3.h.
*/
#ifndef SQLITE3EXT_H
#define SQLITE3EXT_H
/*
** The following structure holds pointers to all of the SQLite API
** routines.
**
** WARNING: In order to maintain backwards compatibility, add new
** interfaces to the end of this structure only. If you insert new
** interfaces in the middle of this structure, then older different
** versions of SQLite will not be able to load each other's shared
** libraries!
*/
struct sqlite3_api_routines {
void * (*aggregate_context)(sqlite3_context*,int nBytes);
int (*aggregate_count)(sqlite3_context*);
int (*bind_blob)(sqlite3_stmt*,int,const void*,int n,void(*)(void*));
int (*bind_double)(sqlite3_stmt*,int,double);
int (*bind_int)(sqlite3_stmt*,int,int);
int (*bind_int64)(sqlite3_stmt*,int,sqlite_int64);
int (*bind_null)(sqlite3_stmt*,int);
int (*bind_parameter_count)(sqlite3_stmt*);
int (*bind_parameter_index)(sqlite3_stmt*,const char*zName);
const char * (*bind_parameter_name)(sqlite3_stmt*,int);
int (*bind_text)(sqlite3_stmt*,int,const char*,int n,void(*)(void*));
int (*bind_text16)(sqlite3_stmt*,int,const void*,int,void(*)(void*));
int (*bind_value)(sqlite3_stmt*,int,const sqlite3_value*);
int (*busy_handler)(sqlite3*,int(*)(void*,int),void*);
int (*busy_timeout)(sqlite3*,int ms);
int (*changes)(sqlite3*);
int (*close)(sqlite3*);
int (*collation_needed)(sqlite3*,void*,void(*)(void*,sqlite3*,
int eTextRep,const char*));
int (*collation_needed16)(sqlite3*,void*,void(*)(void*,sqlite3*,
int eTextRep,const void*));
const void * (*column_blob)(sqlite3_stmt*,int iCol);
int (*column_bytes)(sqlite3_stmt*,int iCol);
int (*column_bytes16)(sqlite3_stmt*,int iCol);
int (*column_count)(sqlite3_stmt*pStmt);
const char * (*column_database_name)(sqlite3_stmt*,int);
const void * (*column_database_name16)(sqlite3_stmt*,int);
const char * (*column_decltype)(sqlite3_stmt*,int i);
const void * (*column_decltype16)(sqlite3_stmt*,int);
double (*column_double)(sqlite3_stmt*,int iCol);
int (*column_int)(sqlite3_stmt*,int iCol);
sqlite_int64 (*column_int64)(sqlite3_stmt*,int iCol);
const char * (*column_name)(sqlite3_stmt*,int);
const void * (*column_name16)(sqlite3_stmt*,int);
const char * (*column_origin_name)(sqlite3_stmt*,int);
const void * (*column_origin_name16)(sqlite3_stmt*,int);
const char * (*column_table_name)(sqlite3_stmt*,int);
const void * (*column_table_name16)(sqlite3_stmt*,int);
const unsigned char * (*column_text)(sqlite3_stmt*,int iCol);
const void * (*column_text16)(sqlite3_stmt*,int iCol);
int (*column_type)(sqlite3_stmt*,int iCol);
sqlite3_value* (*column_value)(sqlite3_stmt*,int iCol);
void * (*commit_hook)(sqlite3*,int(*)(void*),void*);
int (*complete)(const char*sql);
int (*complete16)(const void*sql);
int (*create_collation)(sqlite3*,const char*,int,void*,
int(*)(void*,int,const void*,int,const void*));
int (*create_collation16)(sqlite3*,const void*,int,void*,
int(*)(void*,int,const void*,int,const void*));
int (*create_function)(sqlite3*,const char*,int,int,void*,
void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
void (*xFinal)(sqlite3_context*));
int (*create_function16)(sqlite3*,const void*,int,int,void*,
void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
void (*xFinal)(sqlite3_context*));
int (*create_module)(sqlite3*,const char*,const sqlite3_module*,void*);
int (*data_count)(sqlite3_stmt*pStmt);
sqlite3 * (*db_handle)(sqlite3_stmt*);
int (*declare_vtab)(sqlite3*,const char*);
int (*enable_shared_cache)(int);
int (*errcode)(sqlite3*db);
const char * (*errmsg)(sqlite3*);
const void * (*errmsg16)(sqlite3*);
int (*exec)(sqlite3*,const char*,sqlite3_callback,void*,char**);
int (*expired)(sqlite3_stmt*);
int (*finalize)(sqlite3_stmt*pStmt);
void (*free)(void*);
void (*free_table)(char**result);
int (*get_autocommit)(sqlite3*);
void * (*get_auxdata)(sqlite3_context*,int);
int (*get_table)(sqlite3*,const char*,char***,int*,int*,char**);
int (*global_recover)(void);
void (*interruptx)(sqlite3*);
sqlite_int64 (*last_insert_rowid)(sqlite3*);
const char * (*libversion)(void);
int (*libversion_number)(void);
void *(*malloc)(int);
char * (*mprintf)(const char*,...);
int (*open)(const char*,sqlite3**);
int (*open16)(const void*,sqlite3**);
int (*prepare)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);
int (*prepare16)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);
void * (*profile)(sqlite3*,void(*)(void*,const char*,sqlite_uint64),void*);
void (*progress_handler)(sqlite3*,int,int(*)(void*),void*);
void *(*realloc)(void*,int);
int (*reset)(sqlite3_stmt*pStmt);
void (*result_blob)(sqlite3_context*,const void*,int,void(*)(void*));
void (*result_double)(sqlite3_context*,double);
void (*result_error)(sqlite3_context*,const char*,int);
void (*result_error16)(sqlite3_context*,const void*,int);
void (*result_int)(sqlite3_context*,int);
void (*result_int64)(sqlite3_context*,sqlite_int64);
void (*result_null)(sqlite3_context*);
void (*result_text)(sqlite3_context*,const char*,int,void(*)(void*));
void (*result_text16)(sqlite3_context*,const void*,int,void(*)(void*));
void (*result_text16be)(sqlite3_context*,const void*,int,void(*)(void*));
void (*result_text16le)(sqlite3_context*,const void*,int,void(*)(void*));
void (*result_value)(sqlite3_context*,sqlite3_value*);
void * (*rollback_hook)(sqlite3*,void(*)(void*),void*);
int (*set_authorizer)(sqlite3*,int(*)(void*,int,const char*,const char*,
const char*,const char*),void*);
void (*set_auxdata)(sqlite3_context*,int,void*,void (*)(void*));
char * (*xsnprintf)(int,char*,const char*,...);
int (*step)(sqlite3_stmt*);
int (*table_column_metadata)(sqlite3*,const char*,const char*,const char*,
char const**,char const**,int*,int*,int*);
void (*thread_cleanup)(void);
int (*total_changes)(sqlite3*);
void * (*trace)(sqlite3*,void(*xTrace)(void*,const char*),void*);
int (*transfer_bindings)(sqlite3_stmt*,sqlite3_stmt*);
void * (*update_hook)(sqlite3*,void(*)(void*,int ,char const*,char const*,
sqlite_int64),void*);
void * (*user_data)(sqlite3_context*);
const void * (*value_blob)(sqlite3_value*);
int (*value_bytes)(sqlite3_value*);
int (*value_bytes16)(sqlite3_value*);
double (*value_double)(sqlite3_value*);
int (*value_int)(sqlite3_value*);
sqlite_int64 (*value_int64)(sqlite3_value*);
int (*value_numeric_type)(sqlite3_value*);
const unsigned char * (*value_text)(sqlite3_value*);
const void * (*value_text16)(sqlite3_value*);
const void * (*value_text16be)(sqlite3_value*);
const void * (*value_text16le)(sqlite3_value*);
int (*value_type)(sqlite3_value*);
char *(*vmprintf)(const char*,va_list);
/* Added ??? */
int (*overload_function)(sqlite3*, const char *zFuncName, int nArg);
/* Added by 3.3.13 */
int (*prepare_v2)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);
int (*prepare16_v2)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);
int (*clear_bindings)(sqlite3_stmt*);
/* Added by 3.4.1 */
int (*create_module_v2)(sqlite3*,const char*,const sqlite3_module*,void*,
void (*xDestroy)(void *));
/* Added by 3.5.0 */
int (*bind_zeroblob)(sqlite3_stmt*,int,int);
int (*blob_bytes)(sqlite3_blob*);
int (*blob_close)(sqlite3_blob*);
int (*blob_open)(sqlite3*,const char*,const char*,const char*,sqlite3_int64,
int,sqlite3_blob**);
int (*blob_read)(sqlite3_blob*,void*,int,int);
int (*blob_write)(sqlite3_blob*,const void*,int,int);
int (*create_collation_v2)(sqlite3*,const char*,int,void*,
int(*)(void*,int,const void*,int,const void*),
void(*)(void*));
int (*file_control)(sqlite3*,const char*,int,void*);
sqlite3_int64 (*memory_highwater)(int);
sqlite3_int64 (*memory_used)(void);
sqlite3_mutex *(*mutex_alloc)(int);
void (*mutex_enter)(sqlite3_mutex*);
void (*mutex_free)(sqlite3_mutex*);
void (*mutex_leave)(sqlite3_mutex*);
int (*mutex_try)(sqlite3_mutex*);
int (*open_v2)(const char*,sqlite3**,int,const char*);
int (*release_memory)(int);
void (*result_error_nomem)(sqlite3_context*);
void (*result_error_toobig)(sqlite3_context*);
int (*sleep)(int);
void (*soft_heap_limit)(int);
sqlite3_vfs *(*vfs_find)(const char*);
int (*vfs_register)(sqlite3_vfs*,int);
int (*vfs_unregister)(sqlite3_vfs*);
int (*xthreadsafe)(void);
void (*result_zeroblob)(sqlite3_context*,int);
void (*result_error_code)(sqlite3_context*,int);
int (*test_control)(int, ...);
void (*randomness)(int,void*);
sqlite3 *(*context_db_handle)(sqlite3_context*);
int (*extended_result_codes)(sqlite3*,int);
int (*limit)(sqlite3*,int,int);
sqlite3_stmt *(*next_stmt)(sqlite3*,sqlite3_stmt*);
const char *(*sql)(sqlite3_stmt*);
int (*status)(int,int*,int*,int);
int (*backup_finish)(sqlite3_backup*);
sqlite3_backup *(*backup_init)(sqlite3*,const char*,sqlite3*,const char*);
int (*backup_pagecount)(sqlite3_backup*);
int (*backup_remaining)(sqlite3_backup*);
int (*backup_step)(sqlite3_backup*,int);
const char *(*compileoption_get)(int);
int (*compileoption_used)(const char*);
int (*create_function_v2)(sqlite3*,const char*,int,int,void*,
void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
void (*xFinal)(sqlite3_context*),
void(*xDestroy)(void*));
int (*db_config)(sqlite3*,int,...);
sqlite3_mutex *(*db_mutex)(sqlite3*);
int (*db_status)(sqlite3*,int,int*,int*,int);
int (*extended_errcode)(sqlite3*);
void (*log)(int,const char*,...);
sqlite3_int64 (*soft_heap_limit64)(sqlite3_int64);
const char *(*sourceid)(void);
int (*stmt_status)(sqlite3_stmt*,int,int);
int (*strnicmp)(const char*,const char*,int);
int (*unlock_notify)(sqlite3*,void(*)(void**,int),void*);
int (*wal_autocheckpoint)(sqlite3*,int);
int (*wal_checkpoint)(sqlite3*,const char*);
void *(*wal_hook)(sqlite3*,int(*)(void*,sqlite3*,const char*,int),void*);
int (*blob_reopen)(sqlite3_blob*,sqlite3_int64);
int (*vtab_config)(sqlite3*,int op,...);
int (*vtab_on_conflict)(sqlite3*);
/* Version 3.7.16 and later */
int (*close_v2)(sqlite3*);
const char *(*db_filename)(sqlite3*,const char*);
int (*db_readonly)(sqlite3*,const char*);
int (*db_release_memory)(sqlite3*);
const char *(*errstr)(int);
int (*stmt_busy)(sqlite3_stmt*);
int (*stmt_readonly)(sqlite3_stmt*);
int (*stricmp)(const char*,const char*);
int (*uri_boolean)(const char*,const char*,int);
sqlite3_int64 (*uri_int64)(const char*,const char*,sqlite3_int64);
const char *(*uri_parameter)(const char*,const char*);
char *(*xvsnprintf)(int,char*,const char*,va_list);
int (*wal_checkpoint_v2)(sqlite3*,const char*,int,int*,int*);
/* Version 3.8.7 and later */
int (*auto_extension)(void(*)(void));
int (*bind_blob64)(sqlite3_stmt*,int,const void*,sqlite3_uint64,
void(*)(void*));
int (*bind_text64)(sqlite3_stmt*,int,const char*,sqlite3_uint64,
void(*)(void*),unsigned char);
int (*cancel_auto_extension)(void(*)(void));
int (*load_extension)(sqlite3*,const char*,const char*,char**);
void *(*malloc64)(sqlite3_uint64);
sqlite3_uint64 (*msize)(void*);
void *(*realloc64)(void*,sqlite3_uint64);
void (*reset_auto_extension)(void);
void (*result_blob64)(sqlite3_context*,const void*,sqlite3_uint64,
void(*)(void*));
void (*result_text64)(sqlite3_context*,const char*,sqlite3_uint64,
void(*)(void*), unsigned char);
int (*strglob)(const char*,const char*);
/* Version 3.8.11 and later */
sqlite3_value *(*value_dup)(const sqlite3_value*);
void (*value_free)(sqlite3_value*);
int (*result_zeroblob64)(sqlite3_context*,sqlite3_uint64);
int (*bind_zeroblob64)(sqlite3_stmt*, int, sqlite3_uint64);
/* Version 3.9.0 and later */
unsigned int (*value_subtype)(sqlite3_value*);
void (*result_subtype)(sqlite3_context*,unsigned int);
/* Version 3.10.0 and later */
int (*status64)(int,sqlite3_int64*,sqlite3_int64*,int);
int (*strlike)(const char*,const char*,unsigned int);
int (*db_cacheflush)(sqlite3*);
/* Version 3.12.0 and later */
int (*system_errno)(sqlite3*);
/* Version 3.14.0 and later */
int (*trace_v2)(sqlite3*,unsigned,int(*)(unsigned,void*,void*,void*),void*);
char *(*expanded_sql)(sqlite3_stmt*);
/* Version 3.18.0 and later */
void (*set_last_insert_rowid)(sqlite3*,sqlite3_int64);
/* Version 3.20.0 and later */
int (*prepare_v3)(sqlite3*,const char*,int,unsigned int,
sqlite3_stmt**,const char**);
int (*prepare16_v3)(sqlite3*,const void*,int,unsigned int,
sqlite3_stmt**,const void**);
int (*bind_pointer)(sqlite3_stmt*,int,void*,const char*,void(*)(void*));
void (*result_pointer)(sqlite3_context*,void*,const char*,void(*)(void*));
void *(*value_pointer)(sqlite3_value*,const char*);
int (*vtab_nochange)(sqlite3_context*);
int (*value_nochange)(sqlite3_value*);
const char *(*vtab_collation)(sqlite3_index_info*,int);
/* Version 3.24.0 and later */
int (*keyword_count)(void);
int (*keyword_name)(int,const char**,int*);
int (*keyword_check)(const char*,int);
sqlite3_str *(*str_new)(sqlite3*);
char *(*str_finish)(sqlite3_str*);
void (*str_appendf)(sqlite3_str*, const char *zFormat, ...);
void (*str_vappendf)(sqlite3_str*, const char *zFormat, va_list);
void (*str_append)(sqlite3_str*, const char *zIn, int N);
void (*str_appendall)(sqlite3_str*, const char *zIn);
void (*str_appendchar)(sqlite3_str*, int N, char C);
void (*str_reset)(sqlite3_str*);
int (*str_errcode)(sqlite3_str*);
int (*str_length)(sqlite3_str*);
char *(*str_value)(sqlite3_str*);
/* Version 3.25.0 and later */
int (*create_window_function)(sqlite3*,const char*,int,int,void*,
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
void (*xFinal)(sqlite3_context*),
void (*xValue)(sqlite3_context*),
void (*xInv)(sqlite3_context*,int,sqlite3_value**),
void(*xDestroy)(void*));
/* Version 3.26.0 and later */
const char *(*normalized_sql)(sqlite3_stmt*);
/* Version 3.28.0 and later */
int (*stmt_isexplain)(sqlite3_stmt*);
int (*value_frombind)(sqlite3_value*);
/* Version 3.30.0 and later */
int (*drop_modules)(sqlite3*,const char**);
/* Version 3.31.0 and later */
sqlite3_int64 (*hard_heap_limit64)(sqlite3_int64);
const char *(*uri_key)(const char*,int);
const char *(*filename_database)(const char*);
const char *(*filename_journal)(const char*);
const char *(*filename_wal)(const char*);
/* Version 3.32.0 and later */
const char *(*create_filename)(const char*,const char*,const char*,
int,const char**);
void (*free_filename)(const char*);
sqlite3_file *(*database_file_object)(const char*);
/* Version 3.34.0 and later */
int (*txn_state)(sqlite3*,const char*);
/* Version 3.36.1 and later */
sqlite3_int64 (*changes64)(sqlite3*);
sqlite3_int64 (*total_changes64)(sqlite3*);
/* Version 3.37.0 and later */
int (*autovacuum_pages)(sqlite3*,
unsigned int(*)(void*,const char*,unsigned int,unsigned int,unsigned int),
void*, void(*)(void*));
/* Version 3.38.0 and later */
int (*error_offset)(sqlite3*);
int (*vtab_rhs_value)(sqlite3_index_info*,int,sqlite3_value**);
int (*vtab_distinct)(sqlite3_index_info*);
int (*vtab_in)(sqlite3_index_info*,int,int);
int (*vtab_in_first)(sqlite3_value*,sqlite3_value**);
int (*vtab_in_next)(sqlite3_value*,sqlite3_value**);
/* Version 3.39.0 and later */
int (*deserialize)(sqlite3*,const char*,unsigned char*,
sqlite3_int64,sqlite3_int64,unsigned);
unsigned char *(*serialize)(sqlite3*,const char *,sqlite3_int64*,
unsigned int);
const char *(*db_name)(sqlite3*,int);
/* Version 3.40.0 and later */
int (*value_encoding)(sqlite3_value*);
/* Version 3.41.0 and later */
int (*is_interrupted)(sqlite3*);
/* Version 3.43.0 and later */
int (*stmt_explain)(sqlite3_stmt*,int);
};
/*
** This is the function signature used for all extension entry points. It
** is also defined in the file "loadext.c".
*/
typedef int (*sqlite3_loadext_entry)(
sqlite3 *db, /* Handle to the database. */
char **pzErrMsg, /* Used to set error string on failure. */
const sqlite3_api_routines *pThunk /* Extension API function pointers. */
);
/*
** The following macros redefine the API routines so that they are
** redirected through the global sqlite3_api structure.
**
** This header file is also used by the loadext.c source file
** (part of the main SQLite library - not an extension) so that
** it can get access to the sqlite3_api_routines structure
** definition. But the main library does not want to redefine
** the API. So the redefinition macros are only valid if the
** SQLITE_CORE macros is undefined.
*/
#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
#define sqlite3_aggregate_context sqlite3_api->aggregate_context
#ifndef SQLITE_OMIT_DEPRECATED
#define sqlite3_aggregate_count sqlite3_api->aggregate_count
#endif
#define sqlite3_bind_blob sqlite3_api->bind_blob
#define sqlite3_bind_double sqlite3_api->bind_double
#define sqlite3_bind_int sqlite3_api->bind_int
#define sqlite3_bind_int64 sqlite3_api->bind_int64
#define sqlite3_bind_null sqlite3_api->bind_null
#define sqlite3_bind_parameter_count sqlite3_api->bind_parameter_count
#define sqlite3_bind_parameter_index sqlite3_api->bind_parameter_index
#define sqlite3_bind_parameter_name sqlite3_api->bind_parameter_name
#define sqlite3_bind_text sqlite3_api->bind_text
#define sqlite3_bind_text16 sqlite3_api->bind_text16
#define sqlite3_bind_value sqlite3_api->bind_value
#define sqlite3_busy_handler sqlite3_api->busy_handler
#define sqlite3_busy_timeout sqlite3_api->busy_timeout
#define sqlite3_changes sqlite3_api->changes
#define sqlite3_close sqlite3_api->close
#define sqlite3_collation_needed sqlite3_api->collation_needed
#define sqlite3_collation_needed16 sqlite3_api->collation_needed16
#define sqlite3_column_blob sqlite3_api->column_blob
#define sqlite3_column_bytes sqlite3_api->column_bytes
#define sqlite3_column_bytes16 sqlite3_api->column_bytes16
#define sqlite3_column_count sqlite3_api->column_count
#define sqlite3_column_database_name sqlite3_api->column_database_name
#define sqlite3_column_database_name16 sqlite3_api->column_database_name16
#define sqlite3_column_decltype sqlite3_api->column_decltype
#define sqlite3_column_decltype16 sqlite3_api->column_decltype16
#define sqlite3_column_double sqlite3_api->column_double
#define sqlite3_column_int sqlite3_api->column_int
#define sqlite3_column_int64 sqlite3_api->column_int64
#define sqlite3_column_name sqlite3_api->column_name
#define sqlite3_column_name16 sqlite3_api->column_name16
#define sqlite3_column_origin_name sqlite3_api->column_origin_name
#define sqlite3_column_origin_name16 sqlite3_api->column_origin_name16
#define sqlite3_column_table_name sqlite3_api->column_table_name
#define sqlite3_column_table_name16 sqlite3_api->column_table_name16
#define sqlite3_column_text sqlite3_api->column_text
#define sqlite3_column_text16 sqlite3_api->column_text16
#define sqlite3_column_type sqlite3_api->column_type
#define sqlite3_column_value sqlite3_api->column_value
#define sqlite3_commit_hook sqlite3_api->commit_hook
#define sqlite3_complete sqlite3_api->complete
#define sqlite3_complete16 sqlite3_api->complete16
#define sqlite3_create_collation sqlite3_api->create_collation
#define sqlite3_create_collation16 sqlite3_api->create_collation16
#define sqlite3_create_function sqlite3_api->create_function
#define sqlite3_create_function16 sqlite3_api->create_function16
#define sqlite3_create_module sqlite3_api->create_module
#define sqlite3_create_module_v2 sqlite3_api->create_module_v2
#define sqlite3_data_count sqlite3_api->data_count
#define sqlite3_db_handle sqlite3_api->db_handle
#define sqlite3_declare_vtab sqlite3_api->declare_vtab
#define sqlite3_enable_shared_cache sqlite3_api->enable_shared_cache
#define sqlite3_errcode sqlite3_api->errcode
#define sqlite3_errmsg sqlite3_api->errmsg
#define sqlite3_errmsg16 sqlite3_api->errmsg16
#define sqlite3_exec sqlite3_api->exec
#ifndef SQLITE_OMIT_DEPRECATED
#define sqlite3_expired sqlite3_api->expired
#endif
#define sqlite3_finalize sqlite3_api->finalize
#define sqlite3_free sqlite3_api->free
#define sqlite3_free_table sqlite3_api->free_table
#define sqlite3_get_autocommit sqlite3_api->get_autocommit
#define sqlite3_get_auxdata sqlite3_api->get_auxdata
#define sqlite3_get_table sqlite3_api->get_table
#ifndef SQLITE_OMIT_DEPRECATED
#define sqlite3_global_recover sqlite3_api->global_recover
#endif
#define sqlite3_interrupt sqlite3_api->interruptx
#define sqlite3_last_insert_rowid sqlite3_api->last_insert_rowid
#define sqlite3_libversion sqlite3_api->libversion
#define sqlite3_libversion_number sqlite3_api->libversion_number
#define sqlite3_malloc sqlite3_api->malloc
#define sqlite3_mprintf sqlite3_api->mprintf
#define sqlite3_open sqlite3_api->open
#define sqlite3_open16 sqlite3_api->open16
#define sqlite3_prepare sqlite3_api->prepare
#define sqlite3_prepare16 sqlite3_api->prepare16
#define sqlite3_prepare_v2 sqlite3_api->prepare_v2
#define sqlite3_prepare16_v2 sqlite3_api->prepare16_v2
#define sqlite3_profile sqlite3_api->profile
#define sqlite3_progress_handler sqlite3_api->progress_handler
#define sqlite3_realloc sqlite3_api->realloc
#define sqlite3_reset sqlite3_api->reset
#define sqlite3_result_blob sqlite3_api->result_blob
#define sqlite3_result_double sqlite3_api->result_double
#define sqlite3_result_error sqlite3_api->result_error
#define sqlite3_result_error16 sqlite3_api->result_error16
#define sqlite3_result_int sqlite3_api->result_int
#define sqlite3_result_int64 sqlite3_api->result_int64
#define sqlite3_result_null sqlite3_api->result_null
#define sqlite3_result_text sqlite3_api->result_text
#define sqlite3_result_text16 sqlite3_api->result_text16
#define sqlite3_result_text16be sqlite3_api->result_text16be
#define sqlite3_result_text16le sqlite3_api->result_text16le
#define sqlite3_result_value sqlite3_api->result_value
#define sqlite3_rollback_hook sqlite3_api->rollback_hook
#define sqlite3_set_authorizer sqlite3_api->set_authorizer
#define sqlite3_set_auxdata sqlite3_api->set_auxdata
#define sqlite3_snprintf sqlite3_api->xsnprintf
#define sqlite3_step sqlite3_api->step
#define sqlite3_table_column_metadata sqlite3_api->table_column_metadata
#define sqlite3_thread_cleanup sqlite3_api->thread_cleanup
#define sqlite3_total_changes sqlite3_api->total_changes
#define sqlite3_trace sqlite3_api->trace
#ifndef SQLITE_OMIT_DEPRECATED
#define sqlite3_transfer_bindings sqlite3_api->transfer_bindings
#endif
#define sqlite3_update_hook sqlite3_api->update_hook
#define sqlite3_user_data sqlite3_api->user_data
#define sqlite3_value_blob sqlite3_api->value_blob
#define sqlite3_value_bytes sqlite3_api->value_bytes
#define sqlite3_value_bytes16 sqlite3_api->value_bytes16
#define sqlite3_value_double sqlite3_api->value_double
#define sqlite3_value_int sqlite3_api->value_int
#define sqlite3_value_int64 sqlite3_api->value_int64
#define sqlite3_value_numeric_type sqlite3_api->value_numeric_type
#define sqlite3_value_text sqlite3_api->value_text
#define sqlite3_value_text16 sqlite3_api->value_text16
#define sqlite3_value_text16be sqlite3_api->value_text16be
#define sqlite3_value_text16le sqlite3_api->value_text16le
#define sqlite3_value_type sqlite3_api->value_type
#define sqlite3_vmprintf sqlite3_api->vmprintf
#define sqlite3_vsnprintf sqlite3_api->xvsnprintf
#define sqlite3_overload_function sqlite3_api->overload_function
#define sqlite3_prepare_v2 sqlite3_api->prepare_v2
#define sqlite3_prepare16_v2 sqlite3_api->prepare16_v2
#define sqlite3_clear_bindings sqlite3_api->clear_bindings
#define sqlite3_bind_zeroblob sqlite3_api->bind_zeroblob
#define sqlite3_blob_bytes sqlite3_api->blob_bytes
#define sqlite3_blob_close sqlite3_api->blob_close
#define sqlite3_blob_open sqlite3_api->blob_open
#define sqlite3_blob_read sqlite3_api->blob_read
#define sqlite3_blob_write sqlite3_api->blob_write
#define sqlite3_create_collation_v2 sqlite3_api->create_collation_v2
#define sqlite3_file_control sqlite3_api->file_control
#define sqlite3_memory_highwater sqlite3_api->memory_highwater
#define sqlite3_memory_used sqlite3_api->memory_used
#define sqlite3_mutex_alloc sqlite3_api->mutex_alloc
#define sqlite3_mutex_enter sqlite3_api->mutex_enter
#define sqlite3_mutex_free sqlite3_api->mutex_free
#define sqlite3_mutex_leave sqlite3_api->mutex_leave
#define sqlite3_mutex_try sqlite3_api->mutex_try
#define sqlite3_open_v2 sqlite3_api->open_v2
#define sqlite3_release_memory sqlite3_api->release_memory
#define sqlite3_result_error_nomem sqlite3_api->result_error_nomem
#define sqlite3_result_error_toobig sqlite3_api->result_error_toobig
#define sqlite3_sleep sqlite3_api->sleep
#define sqlite3_soft_heap_limit sqlite3_api->soft_heap_limit
#define sqlite3_vfs_find sqlite3_api->vfs_find
#define sqlite3_vfs_register sqlite3_api->vfs_register
#define sqlite3_vfs_unregister sqlite3_api->vfs_unregister
#define sqlite3_threadsafe sqlite3_api->xthreadsafe
#define sqlite3_result_zeroblob sqlite3_api->result_zeroblob
#define sqlite3_result_error_code sqlite3_api->result_error_code
#define sqlite3_test_control sqlite3_api->test_control
#define sqlite3_randomness sqlite3_api->randomness
#define sqlite3_context_db_handle sqlite3_api->context_db_handle
#define sqlite3_extended_result_codes sqlite3_api->extended_result_codes
#define sqlite3_limit sqlite3_api->limit
#define sqlite3_next_stmt sqlite3_api->next_stmt
#define sqlite3_sql sqlite3_api->sql
#define sqlite3_status sqlite3_api->status
#define sqlite3_backup_finish sqlite3_api->backup_finish
#define sqlite3_backup_init sqlite3_api->backup_init
#define sqlite3_backup_pagecount sqlite3_api->backup_pagecount
#define sqlite3_backup_remaining sqlite3_api->backup_remaining
#define sqlite3_backup_step sqlite3_api->backup_step
#define sqlite3_compileoption_get sqlite3_api->compileoption_get
#define sqlite3_compileoption_used sqlite3_api->compileoption_used
#define sqlite3_create_function_v2 sqlite3_api->create_function_v2
#define sqlite3_db_config sqlite3_api->db_config
#define sqlite3_db_mutex sqlite3_api->db_mutex
#define sqlite3_db_status sqlite3_api->db_status
#define sqlite3_extended_errcode sqlite3_api->extended_errcode
#define sqlite3_log sqlite3_api->log
#define sqlite3_soft_heap_limit64 sqlite3_api->soft_heap_limit64
#define sqlite3_sourceid sqlite3_api->sourceid
#define sqlite3_stmt_status sqlite3_api->stmt_status
#define sqlite3_strnicmp sqlite3_api->strnicmp
#define sqlite3_unlock_notify sqlite3_api->unlock_notify
#define sqlite3_wal_autocheckpoint sqlite3_api->wal_autocheckpoint
#define sqlite3_wal_checkpoint sqlite3_api->wal_checkpoint
#define sqlite3_wal_hook sqlite3_api->wal_hook
#define sqlite3_blob_reopen sqlite3_api->blob_reopen
#define sqlite3_vtab_config sqlite3_api->vtab_config
#define sqlite3_vtab_on_conflict sqlite3_api->vtab_on_conflict
/* Version 3.7.16 and later */
#define sqlite3_close_v2 sqlite3_api->close_v2
#define sqlite3_db_filename sqlite3_api->db_filename
#define sqlite3_db_readonly sqlite3_api->db_readonly
#define sqlite3_db_release_memory sqlite3_api->db_release_memory
#define sqlite3_errstr sqlite3_api->errstr
#define sqlite3_stmt_busy sqlite3_api->stmt_busy
#define sqlite3_stmt_readonly sqlite3_api->stmt_readonly
#define sqlite3_stricmp sqlite3_api->stricmp
#define sqlite3_uri_boolean sqlite3_api->uri_boolean
#define sqlite3_uri_int64 sqlite3_api->uri_int64
#define sqlite3_uri_parameter sqlite3_api->uri_parameter
#define sqlite3_uri_vsnprintf sqlite3_api->xvsnprintf
#define sqlite3_wal_checkpoint_v2 sqlite3_api->wal_checkpoint_v2
/* Version 3.8.7 and later */
#define sqlite3_auto_extension sqlite3_api->auto_extension
#define sqlite3_bind_blob64 sqlite3_api->bind_blob64
#define sqlite3_bind_text64 sqlite3_api->bind_text64
#define sqlite3_cancel_auto_extension sqlite3_api->cancel_auto_extension
#define sqlite3_load_extension sqlite3_api->load_extension
#define sqlite3_malloc64 sqlite3_api->malloc64
#define sqlite3_msize sqlite3_api->msize
#define sqlite3_realloc64 sqlite3_api->realloc64
#define sqlite3_reset_auto_extension sqlite3_api->reset_auto_extension
#define sqlite3_result_blob64 sqlite3_api->result_blob64
#define sqlite3_result_text64 sqlite3_api->result_text64
#define sqlite3_strglob sqlite3_api->strglob
/* Version 3.8.11 and later */
#define sqlite3_value_dup sqlite3_api->value_dup
#define sqlite3_value_free sqlite3_api->value_free
#define sqlite3_result_zeroblob64 sqlite3_api->result_zeroblob64
#define sqlite3_bind_zeroblob64 sqlite3_api->bind_zeroblob64
/* Version 3.9.0 and later */
#define sqlite3_value_subtype sqlite3_api->value_subtype
#define sqlite3_result_subtype sqlite3_api->result_subtype
/* Version 3.10.0 and later */
#define sqlite3_status64 sqlite3_api->status64
#define sqlite3_strlike sqlite3_api->strlike
#define sqlite3_db_cacheflush sqlite3_api->db_cacheflush
/* Version 3.12.0 and later */
#define sqlite3_system_errno sqlite3_api->system_errno
/* Version 3.14.0 and later */
#define sqlite3_trace_v2 sqlite3_api->trace_v2
#define sqlite3_expanded_sql sqlite3_api->expanded_sql
/* Version 3.18.0 and later */
#define sqlite3_set_last_insert_rowid sqlite3_api->set_last_insert_rowid
/* Version 3.20.0 and later */
#define sqlite3_prepare_v3 sqlite3_api->prepare_v3
#define sqlite3_prepare16_v3 sqlite3_api->prepare16_v3
#define sqlite3_bind_pointer sqlite3_api->bind_pointer
#define sqlite3_result_pointer sqlite3_api->result_pointer
#define sqlite3_value_pointer sqlite3_api->value_pointer
/* Version 3.22.0 and later */
#define sqlite3_vtab_nochange sqlite3_api->vtab_nochange
#define sqlite3_value_nochange sqlite3_api->value_nochange
#define sqlite3_vtab_collation sqlite3_api->vtab_collation
/* Version 3.24.0 and later */
#define sqlite3_keyword_count sqlite3_api->keyword_count
#define sqlite3_keyword_name sqlite3_api->keyword_name
#define sqlite3_keyword_check sqlite3_api->keyword_check
#define sqlite3_str_new sqlite3_api->str_new
#define sqlite3_str_finish sqlite3_api->str_finish
#define sqlite3_str_appendf sqlite3_api->str_appendf
#define sqlite3_str_vappendf sqlite3_api->str_vappendf
#define sqlite3_str_append sqlite3_api->str_append
#define sqlite3_str_appendall sqlite3_api->str_appendall
#define sqlite3_str_appendchar sqlite3_api->str_appendchar
#define sqlite3_str_reset sqlite3_api->str_reset
#define sqlite3_str_errcode sqlite3_api->str_errcode
#define sqlite3_str_length sqlite3_api->str_length
#define sqlite3_str_value sqlite3_api->str_value
/* Version 3.25.0 and later */
#define sqlite3_create_window_function sqlite3_api->create_window_function
/* Version 3.26.0 and later */
#define sqlite3_normalized_sql sqlite3_api->normalized_sql
/* Version 3.28.0 and later */
#define sqlite3_stmt_isexplain sqlite3_api->stmt_isexplain
#define sqlite3_value_frombind sqlite3_api->value_frombind
/* Version 3.30.0 and later */
#define sqlite3_drop_modules sqlite3_api->drop_modules
/* Version 3.31.0 and later */
#define sqlite3_hard_heap_limit64 sqlite3_api->hard_heap_limit64
#define sqlite3_uri_key sqlite3_api->uri_key
#define sqlite3_filename_database sqlite3_api->filename_database
#define sqlite3_filename_journal sqlite3_api->filename_journal
#define sqlite3_filename_wal sqlite3_api->filename_wal
/* Version 3.32.0 and later */
#define sqlite3_create_filename sqlite3_api->create_filename
#define sqlite3_free_filename sqlite3_api->free_filename
#define sqlite3_database_file_object sqlite3_api->database_file_object
/* Version 3.34.0 and later */
#define sqlite3_txn_state sqlite3_api->txn_state
/* Version 3.36.1 and later */
#define sqlite3_changes64 sqlite3_api->changes64
#define sqlite3_total_changes64 sqlite3_api->total_changes64
/* Version 3.37.0 and later */
#define sqlite3_autovacuum_pages sqlite3_api->autovacuum_pages
/* Version 3.38.0 and later */
#define sqlite3_error_offset sqlite3_api->error_offset
#define sqlite3_vtab_rhs_value sqlite3_api->vtab_rhs_value
#define sqlite3_vtab_distinct sqlite3_api->vtab_distinct
#define sqlite3_vtab_in sqlite3_api->vtab_in
#define sqlite3_vtab_in_first sqlite3_api->vtab_in_first
#define sqlite3_vtab_in_next sqlite3_api->vtab_in_next
/* Version 3.39.0 and later */
#ifndef SQLITE_OMIT_DESERIALIZE
#define sqlite3_deserialize sqlite3_api->deserialize
#define sqlite3_serialize sqlite3_api->serialize
#endif
#define sqlite3_db_name sqlite3_api->db_name
/* Version 3.40.0 and later */
#define sqlite3_value_encoding sqlite3_api->value_encoding
/* Version 3.41.0 and later */
#define sqlite3_is_interrupted sqlite3_api->is_interrupted
/* Version 3.43.0 and later */
#define sqlite3_stmt_explain sqlite3_api->stmt_explain
#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
/* This case when the file really is being compiled as a loadable
** extension */
# define SQLITE_EXTENSION_INIT1 const sqlite3_api_routines *sqlite3_api=0;
# define SQLITE_EXTENSION_INIT2(v) sqlite3_api=v;
# define SQLITE_EXTENSION_INIT3 \
extern const sqlite3_api_routines *sqlite3_api;
#else
/* This case when the file is being statically linked into the
** application */
# define SQLITE_EXTENSION_INIT1 /*no-op*/
# define SQLITE_EXTENSION_INIT2(v) (void)v; /* unused parameter */
# define SQLITE_EXTENSION_INIT3 /*no-op*/
#endif
#endif /* SQLITE3EXT_H */

View File

@ -4,5 +4,6 @@ add_subdirectory(raylib-nuklear)
add_library(vendors-bundle STATIC
sfd.c
3rd_sqlite3.c
)

36
code/vendors/enet.h vendored
View File

@ -43,7 +43,7 @@
#define ENET_VERSION_MAJOR 2
#define ENET_VERSION_MINOR 3
#define ENET_VERSION_PATCH 6
#define ENET_VERSION_PATCH 10
#define ENET_VERSION_CREATE(major, minor, patch) (((major)<<16) | ((minor)<<8) | (patch))
#define ENET_VERSION_GET_MAJOR(version) (((version)>>16)&0xFF)
#define ENET_VERSION_GET_MINOR(version) (((version)>>8)&0xFF)
@ -72,9 +72,11 @@
#endif
#ifndef ENET_NO_PRAGMA_LINK
#ifndef __GNUC__
#pragma comment(lib, "ws2_32.lib")
#pragma comment(lib, "winmm.lib")
#endif
#endif
#if _MSC_VER >= 1910
/* It looks like there were changes as of Visual Studio 2017 and there are no 32/64 bit
@ -252,6 +254,7 @@ extern "C" {
extern void *enet_malloc(size_t);
extern void enet_free(void *);
extern ENetPacket* enet_packet_create(const void*,size_t,enet_uint32);
extern ENetPacket* enet_packet_resize(ENetPacket*, size_t);
extern ENetPacket* enet_packet_copy(ENetPacket*);
extern void enet_packet_destroy(ENetPacket*);
@ -611,7 +614,7 @@ extern "C" {
ENET_HOST_RECEIVE_BUFFER_SIZE = 256 * 1024,
ENET_HOST_SEND_BUFFER_SIZE = 256 * 1024,
ENET_HOST_BANDWIDTH_THROTTLE_INTERVAL = 1000,
ENET_HOST_DEFAULT_MTU = 1400,
ENET_HOST_DEFAULT_MTU = 1392,
ENET_HOST_DEFAULT_MAXIMUM_PACKET_SIZE = 32 * 1024 * 1024,
ENET_HOST_DEFAULT_MAXIMUM_WAITING_DATA = 32 * 1024 * 1024,
@ -1389,6 +1392,35 @@ extern "C" {
return packet;
}
/** Attempts to resize the data in the packet to length specified in the
dataLength parameter
@param packet packet to resize
@param dataLength new size for the packet data
@returns new packet pointer on success, NULL on failure
*/
ENetPacket* enet_packet_resize(ENetPacket * packet, size_t dataLength)
{
ENetPacket *newPacket = NULL;
if (dataLength <= packet->dataLength || (packet->flags & ENET_PACKET_FLAG_NO_ALLOCATE))
{
packet->dataLength = dataLength;
return packet;
}
newPacket = (ENetPacket *)enet_malloc(sizeof (ENetPacket) + dataLength);
if (newPacket == NULL)
return NULL;
memcpy(newPacket, packet, sizeof(ENetPacket) + packet->dataLength);
newPacket->data = (enet_uint8 *)newPacket + sizeof(ENetPacket);
newPacket->dataLength = dataLength;
enet_free(packet);
return newPacket;
}
ENetPacket *enet_packet_create_offset(const void *data, size_t dataLength, size_t dataOffset, enet_uint32 flags) {
ENetPacket *packet;
if (flags & ENET_PACKET_FLAG_NO_ALLOCATE) {

62
code/vendors/librg.h vendored
View File

@ -156,8 +156,8 @@
#define LIBRG_H
#define LIBRG_VERSION_MAJOR 7
#define LIBRG_VERSION_MINOR 1
#define LIBRG_VERSION_PATCH 1
#define LIBRG_VERSION_MINOR 3
#define LIBRG_VERSION_PATCH 0
#define LIBRG_VERSION_PRE ""
// file: librg_hedley.h
@ -20707,6 +20707,13 @@ LIBRG_BEGIN_C_DECLS
#error "LIBRG_WORLDWRITE_MAXQUERY must have value less than 65535"
#endif
/* enables the increased data-buffer size for world packing */
#ifdef LIBRG_ENABLE_EXTENDED_EVENTBUFFER
#define LIBRG_WORLDWRITE_DATATYPE uint32_t
#else
#define LIBRG_WORLDWRITE_DATATYPE uint16_t
#endif
// =======================================================================//
// !
// ! Internal data structures
@ -21223,6 +21230,16 @@ int8_t librg_entity_foreign(librg_world *world, int64_t entity_id) {
return entity->flag_foreign == LIBRG_TRUE;
}
int8_t librg_entity_owned(librg_world *world, int64_t entity_id) {
LIBRG_ASSERT(world); if (!world) return LIBRG_FALSE;
librg_world_t *wld = (librg_world_t *)world;
librg_entity_t *entity = librg_table_ent_get(&wld->entity_map, entity_id);
if (entity == NULL) return LIBRG_FALSE;
return entity->owner_id != LIBRG_OWNER_INVALID;
}
int32_t librg_entity_count(librg_world *world) {
LIBRG_ASSERT(world); if (!world) return LIBRG_WORLD_INVALID;
librg_world_t *wld = (librg_world_t *)world;
@ -21457,11 +21474,6 @@ int8_t librg_entity_visibility_owner_set(librg_world *world, int64_t entity_id,
librg_entity_t *entity = librg_table_ent_get(&wld->entity_map, entity_id);
if (entity == NULL) return LIBRG_ENTITY_UNTRACKED;
/* prevent setting visibility, for your own entity, it will be always visible */
if (entity->owner_id == owner_id) {
return LIBRG_ENTITY_VISIBILITY_IGNORED;
}
if (!entity->flag_visbility_owner_enabled) {
entity->flag_visbility_owner_enabled = LIBRG_TRUE;
librg_table_i8_init(&entity->owner_visibility_map, wld->allocator);
@ -21561,7 +21573,8 @@ int32_t librg_world_fetch_chunkarray(librg_world *world, const librg_chunk *chun
}
int32_t librg_world_fetch_owner(librg_world *world, int64_t owner_id, int64_t *entity_ids, size_t *entity_amount) {
return librg_world_fetch_ownerarray(world, (int64_t[]){owner_id}, 1, entity_ids, entity_amount);
int64_t owner_ids[1]; owner_ids[0] = owner_id;
return librg_world_fetch_ownerarray(world, owner_ids, 1, entity_ids, entity_amount);
}
int32_t librg_world_fetch_ownerarray(librg_world *world, const int64_t *owner_ids, size_t owner_amount, int64_t *entity_ids, size_t *entity_amount) {
@ -21636,7 +21649,11 @@ int32_t librg_world_query(librg_world *world, int64_t owner_id, uint8_t chunk_ra
librg_entity_t *entity = librg_table_ent_get(&wld->entity_map, entity_id);
/* allways add self-owned entities */
int8_t vis_owner = librg_entity_visibility_owner_get(world, entity_id, owner_id);
if (vis_owner != LIBRG_VISIBLITY_NEVER) {
/* prevent from being included */
librg_push_entity(entity_id);
}
/* immidiately skip, if entity was not placed correctly */
if (entity->chunks[0] == LIBRG_CHUNK_INVALID) continue;
@ -21739,11 +21756,21 @@ LIBRG_BEGIN_C_DECLS
// !
// =======================================================================//
/* size of the segment */
#define LIBRG_SEGMENT_SIZE 8
/* size of the segment value */
#ifdef LIBRG_ENABLE_EXTENDED_EVENTBUFFER
#define LIBRG_SEGVAL_SIZE 14
#else
#define LIBRG_SEGVAL_SIZE 12
#endif
LIBRG_PRAGMA(pack(push, 1));
typedef struct {
uint64_t id;
uint16_t token;
uint16_t size;
LIBRG_WORLDWRITE_DATATYPE size;
} librg_segval_t;
typedef struct {
@ -21754,8 +21781,8 @@ typedef struct {
} librg_segment_t;
LIBRG_PRAGMA(pack(pop));
LIBRG_STATIC_ASSERT(sizeof(librg_segval_t) == 12, "packed librg_segval_t should have a valid size");
LIBRG_STATIC_ASSERT(sizeof(librg_segment_t) == 8, "packed librg_segment_t should have a valid size");
LIBRG_STATIC_ASSERT(sizeof(librg_segval_t) == LIBRG_SEGVAL_SIZE, "packed librg_segval_t should have a valid size");
LIBRG_STATIC_ASSERT(sizeof(librg_segment_t) == LIBRG_SEGMENT_SIZE, "packed librg_segment_t should have a valid size");
// =======================================================================//
// !
@ -21861,6 +21888,19 @@ librg_lbl_ww:
/* call event handlers */
if (wld->handlers[action_id]) {
data_size = (int32_t)wld->handlers[action_id](world, (librg_event*)&evt);
/* if data size is bigger than the limit, we will notify user about that */
if (data_size > ZPL_I32_MAX) {
ZPL_PANIC("librg: the data size returned by the event handler is too big for the event. \
Ensure that you are not returning more than %d bytes.", ZPL_I32_MAX);
}
#ifndef LIBRG_ENABLE_EXTENDED_EVENTBUFFER
if (data_size > (int32_t)ZPL_U16_MAX) {
ZPL_PANIC("librg: the data size returned by the event handler is bigger than the event buffer size. \
Ensure that you are not returning more than %d bytes.", evt.size);
}
#endif
}
/* if user returned < 0, we consider that event rejected */