Skip to content

Commit

Permalink
Remove unused bindings for C3 functions
Browse files Browse the repository at this point in the history
  • Loading branch information
rexim committed Oct 5, 2024
1 parent c50e550 commit 89f049c
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 164 deletions.
40 changes: 20 additions & 20 deletions client.c3
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ fn void cull_and_sort_sprites(SpritePool *sprite_pool) {
fn int(Sprite *a, Sprite *b) => (int)math::copysign(1.0f, b.pdist - a.pdist));
}

fn void push_sprite(SpritePool *sprite_pool, Image *image, float x, float y, float z, float scale, int crop_position_x, int crop_position_y, int crop_size_x, int crop_size_y) @extern("push_sprite") @wasm {
fn void push_sprite(SpritePool *sprite_pool, Image *image, float x, float y, float z, float scale, int crop_position_x, int crop_position_y, int crop_size_x, int crop_size_y) {
if (sprite_pool.length >= SPRITE_POOL_CAPACITY) return;

usz last = sprite_pool.length;
Expand Down Expand Up @@ -472,7 +472,7 @@ fn void render_sprites(Image *display, float *zbuffer, SpritePool *sprite_pool)
}
}

fn void emit_particle(float source_x, float source_y, float source_z, ParticlePool *particle_pool) @extern("emit_particle") @wasm {
fn void emit_particle(float source_x, float source_y, float source_z, ParticlePool *particle_pool) {
foreach (&particle: particle_pool.items) {
if (particle.lifetime <= 0) {
particle.lifetime = PARTICLE_LIFETIME;
Expand Down Expand Up @@ -537,15 +537,15 @@ fn void kill_all_items(Item[]* items) {
}
}

fn bool verify_items_collected_batch_message(Message *message) @extern("verify_items_collected_batch_message") @wasm {
fn bool verify_items_collected_batch_message(Message *message) {
if (message.size < ItemsCollectedBatchMessage.sizeof) return false;
if ((message.size - ItemsCollectedBatchMessage.sizeof)%int.sizeof != 0) return false;
ItemsCollectedBatchMessage* items_collected_batch_message = (ItemsCollectedBatchMessage*)message;
if (items_collected_batch_message.kind != MessageKind.ITEM_COLLECTED) return false;
return true;
}

fn bool apply_items_collected_batch_message_to_level_items(ItemsCollectedBatchMessage *message, Item[]* items) @extern("apply_items_collected_batch_message_to_level_items") @wasm {
fn bool apply_items_collected_batch_message_to_level_items(ItemsCollectedBatchMessage *message, Item[]* items) {
usz count = (message.size - ItemsCollectedBatchMessage.sizeof)/int.sizeof;

for (usz i = 0; i < count; ++i) {
Expand All @@ -567,15 +567,15 @@ fn bool apply_items_collected_batch_message_to_level_items(ItemsCollectedBatchMe
return true;
}

fn bool verify_items_spawned_batch_message(Message *message) @extern("verify_items_spawned_batch_message") @wasm {
fn bool verify_items_spawned_batch_message(Message *message) {
if (message.size < ItemsSpawnedBatchMessage.sizeof) return false;
if ((message.size - ItemsSpawnedBatchMessage.sizeof)%ItemSpawned.sizeof != 0) return false;
ItemsSpawnedBatchMessage* items_spawned_batch_message = (ItemsSpawnedBatchMessage*)message;
if (items_spawned_batch_message.kind != MessageKind.ITEM_SPAWNED) return false;
return true;
}

fn bool apply_items_spawned_batch_message_to_level_items(ItemsSpawnedBatchMessage *message, Item[]* items) @extern("apply_items_spawned_batch_message_to_level_items") @wasm {
fn bool apply_items_spawned_batch_message_to_level_items(ItemsSpawnedBatchMessage *message, Item[]* items) {
usz count = (message.size - ItemsCollectedBatchMessage.sizeof)/ItemSpawned.sizeof;
for (usz i = 0; i < count; ++i) {
int itemIndex = message.items[i].itemIndex;
Expand All @@ -593,7 +593,7 @@ fn bool apply_items_spawned_batch_message_to_level_items(ItemsSpawnedBatchMessag
return true;
}

fn void render_items(SpritePool *sprite_pool, Item[]* items, float time, Image *key_image, Image *bomb_image) @extern("render_items") @wasm {
fn void render_items(SpritePool *sprite_pool, Item[]* items, float time, Image *key_image, Image *bomb_image) {
foreach (item: *items) {
if (item.alive) {
float z = 0.25f + ITEM_AMP - ITEM_AMP*math::sin(ITEM_FREQ*(float)math::PI*time + item.position.x + item.position.y);
Expand Down Expand Up @@ -659,15 +659,15 @@ fn void update_bombs_on_client_side(SpritePool *sprite_pool, ParticlePool *parti
}
}

fn bool verify_bombs_spawned_batch_message(Message *message) @extern("verify_bombs_spawned_batch_message") @wasm {
fn bool verify_bombs_spawned_batch_message(Message *message) {
if (message.size < BombsSpawnedBatchMessage.sizeof) return false;
if ((message.size - BombsSpawnedBatchMessage.sizeof)%BombSpawned.sizeof != 0) return false;
BombsSpawnedBatchMessage* bombs_spawned_batch_message = (BombsSpawnedBatchMessage*)message;
if (bombs_spawned_batch_message.kind != MessageKind.BOMB_SPAWNED) return false;
return true;
}

fn bool apply_bombs_spawned_batch_message_to_level_items(BombsSpawnedBatchMessage *message, Bombs *bombs) @extern("apply_bombs_spawned_batch_message_to_level_items") @wasm {
fn bool apply_bombs_spawned_batch_message_to_level_items(BombsSpawnedBatchMessage *message, Bombs *bombs) {
usz count = (message.size - BombsSpawnedBatchMessage.sizeof)/BombSpawned.sizeof;
for (usz i = 0; i < count; ++i) {
int bombIndex = message.bombs[i].bombIndex;
Expand All @@ -688,15 +688,15 @@ fn bool apply_bombs_spawned_batch_message_to_level_items(BombsSpawnedBatchMessag
return true;
}

fn bool verify_bombs_exploded_batch_message(Message *message) @extern("verify_bombs_exploded_batch_message") @wasm {
fn bool verify_bombs_exploded_batch_message(Message *message) {
if (message.size < BombsExplodedBatchMessage.sizeof) return false;
if ((message.size - BombsExplodedBatchMessage.sizeof)%BombExploded.sizeof != 0) return false;
BombsExplodedBatchMessage* bombs_exploded_batch_message = (BombsExplodedBatchMessage*)message;
if (bombs_exploded_batch_message.kind != MessageKind.BOMB_EXPLODED) return false;
return true;
}

fn bool apply_bombs_exploded_batch_message_to_level_items(BombsExplodedBatchMessage *message, Bombs *bombs, ParticlePool *particle_pool) @extern("apply_bombs_exploded_batch_message_to_level_items") @wasm {
fn bool apply_bombs_exploded_batch_message_to_level_items(BombsExplodedBatchMessage *message, Bombs *bombs, ParticlePool *particle_pool) {
usz count = (message.size - BombsExplodedBatchMessage.sizeof)/BombExploded.sizeof;
for (usz i = 0; i < count; ++i) {
int bombIndex = message.bombs[i].bombIndex;
Expand Down Expand Up @@ -740,7 +740,7 @@ const Control[*] CONTROL_KEYS = {
{83, MOVING_BACKWARD},
};

fn bool verify_hello_message(Message *message) @extern("verify_hello_message") @wasm {
fn bool verify_hello_message(Message *message) {
if (message.size != HelloMessage.sizeof) return false;
HelloMessage* hello_message = (HelloMessage*)message;
if (hello_message.kind != HELLO) return false;
Expand All @@ -759,15 +759,15 @@ fn void apply_hello_message_to_me(HelloMessage *hello_message, Item[]* items) {
me.hue = hello_message.hue;
}

fn bool verify_players_joined_batch_message(Message *message) @extern("verify_players_joined_batch_message") @wasm {
fn bool verify_players_joined_batch_message(Message *message) {
if (message.size < PlayersJoinedBatchMessage.sizeof) return false;
if ((message.size - PlayersJoinedBatchMessage.sizeof)%PlayerStruct.sizeof != 0) return false;
PlayersJoinedBatchMessage* players_joined_batch_message = (PlayersJoinedBatchMessage*)message;
if (players_joined_batch_message.kind != PLAYER_JOINED) return false;
return true;
}

fn void apply_players_joined_batch_message(PlayersJoinedBatchMessage *message) @extern("apply_players_joined_batch_message") @wasm {
fn void apply_players_joined_batch_message(PlayersJoinedBatchMessage *message) {
usz count = (message.size - PlayersJoinedBatchMessage.sizeof)/PlayerStruct.sizeof;
for (usz i = 0; i < count; ++i) {
PlayerStruct *player_struct = &message.players[i];
Expand Down Expand Up @@ -797,30 +797,30 @@ fn void apply_players_joined_batch_message(PlayersJoinedBatchMessage *message) @
}
}

fn bool verify_players_left_batch_message(Message *message) @extern("verify_players_left_batch_message") @wasm {
fn bool verify_players_left_batch_message(Message *message) {
if (message.size < PlayersLeftBatchMessage.sizeof) return false;
if ((message.size - PlayersLeftBatchMessage.sizeof)%uint.sizeof != 0) return false;
PlayersLeftBatchMessage* players_left_batch_message = (PlayersLeftBatchMessage*)message;
if (players_left_batch_message.kind != PLAYER_LEFT) return false;
return true;
}

fn void apply_players_left_batch_message(PlayersLeftBatchMessage *message) @extern("apply_players_left_batch_message") @wasm {
fn void apply_players_left_batch_message(PlayersLeftBatchMessage *message) {
usz count = (message.size - PlayersLeftBatchMessage.sizeof)/uint.sizeof;
for (usz i = 0; i < count; ++i) {
other_players.remove(message.ids[i]);
}
}

fn bool verify_players_moving_batch_message(Message *message) @extern("verify_players_moving_batch_message") @wasm {
fn bool verify_players_moving_batch_message(Message *message) {
if (message.size < PlayersMovingBatchMessage.sizeof) return false;
if ((message.size - PlayersMovingBatchMessage.sizeof)%PlayerStruct.sizeof != 0) return false;
PlayersMovingBatchMessage* players_moving_batch_message = (PlayersMovingBatchMessage*)message;
if (players_moving_batch_message.kind != PLAYER_MOVING) return false;
return true;
}

fn bool apply_players_moving_batch_message(PlayersMovingBatchMessage *message) @extern("apply_players_moving_batch_message") @wasm {
fn bool apply_players_moving_batch_message(PlayersMovingBatchMessage *message) {
usz count = (message.size - PlayersMovingBatchMessage.sizeof)/PlayerStruct.sizeof;
for (usz i = 0; i < count; ++i) {
PlayerStruct *player_struct = &message.players[i];
Expand Down Expand Up @@ -946,15 +946,15 @@ fn void ping_server_if_needed() @extern("ping_server_if_needed") @wasm {
}
}

fn bool verify_pong_message(Message *message) @extern("verify_pong_message") @wasm {
fn bool verify_pong_message(Message *message) {
if (message.size != PongMessage.sizeof) return false;
PongMessage* pong_message = (PongMessage*)message;
if (pong_message.kind != PONG) return false;
return true;
}

uint ping = 0;
fn void process_pong_message(PongMessage *message) @extern("process_pong_message") @wasm {
fn void process_pong_message(PongMessage *message) {
ping = platform_now_msecs() - message.timestamp;
}

Expand Down
20 changes: 0 additions & 20 deletions client.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -165,37 +165,17 @@ async function instantiateWasmClient(url) {
allocate_sprite_pool: wasm.instance.exports.allocate_sprite_pool,
reset_sprite_pool: wasm.instance.exports.reset_sprite_pool,
render_minimap: wasm.instance.exports.render_minimap,
push_sprite: wasm.instance.exports.push_sprite,
allocate_particle_pool: wasm.instance.exports.allocate_particle_pool,
emit_particle: wasm.instance.exports.emit_particle,
verify_items_collected_batch_message: wasm.instance.exports.verify_items_collected_batch_message,
apply_items_collected_batch_message_to_level_items: wasm.instance.exports.apply_items_collected_batch_message_to_level_items,
verify_items_spawned_batch_message: wasm.instance.exports.verify_items_spawned_batch_message,
apply_items_spawned_batch_message_to_level_items: wasm.instance.exports.apply_items_spawned_batch_message_to_level_items,
render_items: wasm.instance.exports.render_items,
verify_bombs_spawned_batch_message: wasm.instance.exports.verify_bombs_spawned_batch_message,
apply_bombs_spawned_batch_message_to_level_items: wasm.instance.exports.apply_bombs_spawned_batch_message_to_level_items,
verify_bombs_exploded_batch_message: wasm.instance.exports.verify_bombs_exploded_batch_message,
apply_bombs_exploded_batch_message_to_level_items: wasm.instance.exports.apply_bombs_exploded_batch_message_to_level_items,
allocate_image: wasm.instance.exports.allocate_image,
image_width: wasm.instance.exports.image_width,
image_height: wasm.instance.exports.image_height,
image_pixels: wasm.instance.exports.image_pixels,
players_count: wasm.instance.exports.players_count,
unregister_all_other_players: wasm.instance.exports.unregister_all_other_players,
verify_hello_message: wasm.instance.exports.verify_hello_message,
verify_players_joined_batch_message: wasm.instance.exports.verify_players_joined_batch_message,
apply_players_joined_batch_message: wasm.instance.exports.apply_players_joined_batch_message,
verify_players_left_batch_message: wasm.instance.exports.verify_players_left_batch_message,
apply_players_left_batch_message: wasm.instance.exports.apply_players_left_batch_message,
verify_players_moving_batch_message: wasm.instance.exports.verify_players_moving_batch_message,
apply_players_moving_batch_message: wasm.instance.exports.apply_players_moving_batch_message,
key_down: wasm.instance.exports.key_down,
key_up: wasm.instance.exports.key_up,
render_game: wasm.instance.exports.render_game,
ping_server_if_needed: wasm.instance.exports.ping_server_if_needed,
verify_pong_message: wasm.instance.exports.verify_pong_message,
process_pong_message: wasm.instance.exports.process_pong_message,
ping_msecs: wasm.instance.exports.ping_msecs,
process_message: wasm.instance.exports.process_message,
};
Expand Down
Loading

0 comments on commit 89f049c

Please sign in to comment.