This commit is contained in:
2025-06-08 17:22:30 +02:00
parent 64cac7578d
commit 79c8b747cd
16 changed files with 686 additions and 79 deletions

42
util/pathfinding.h Normal file
View File

@@ -0,0 +1,42 @@
//
// Created by bruno on 7.6.2025.
//
#ifndef FACTORYGAME_PATHFINDING_H
#define FACTORYGAME_PATHFINDING_H
#include <stdint.h>
#include "../tiles/tile.h"
//extern uint32_t globalPathfindingVersion;
//#define MAX_OPEN_NODES (MAP_WIDTH * MAP_HEIGHT)
#define MAX_OPEN_NODES 100
typedef struct Node {
MiniRect pos;
int fCost;
} Node;
typedef struct {
MiniRect steps[MAX_OPEN_NODES];
int stepIndex;
int length;
} Path;
extern Node openList[MAX_OPEN_NODES];
extern int openCount;
int heuristic(MiniRect a, MiniRect b);
Path reconstruct_path(MiniRect end);
bool find_path(MiniRect start, MiniRect end);
Node pop_best_node();
void add_to_open(MiniRect pos, int fCost);
void clear_pathfind_data();
#endif //FACTORYGAME_PATHFINDING_H