src/ai/api/ai_pathfinder_stupid.hpp
author truebrain
Thu, 28 Feb 2008 01:11:23 +0000
branchnoai
changeset 9803 c86d5834fb11
parent 9653 50e2eb4abf46
permissions -rw-r--r--
(svn r12309) [NoAI] -Codechange: optimize a little bit (a very small little bit, but every bit counts :) ) (glx)
/* $Id$ */

/** @file ai_pathfinder_stupid.hpp A really stupid pathfinder */

#ifndef AI_PATHFINDER_STUPID_HPP
#define AI_PATHFINDER_STUPID_HPP

#include "ai_pathfinder.hpp"

/**
 * A stupid pathfinder. It first makes a straight line on the X-axis, than
 *  it does the same on the Y-axis. The result is rarely optimal, or connected.
 */
class AIPathFinderStupid : public AIPathFinder {
public:
	/**
	 * The name of the class, needed by several sub-processes.
	 */
	static const char *GetClassName() { return "AIPathFinderStupid"; }

	/**
	 * Custom constructor, to see for which type we are going to be a pathfinder.
	 */
	AIPathFinderStupid(AIPathFinder::PathFinderType type) { this->type = type; }

	void *FindRoute(AITileList *start, AITileList *end);
	bool BuildRoute(void *result);
	void FreeRoute(void *result);

	/** Keep the compilers happy */
	virtual ~AIPathFinderStupid() {}
private:
	AIPathFinder::PathFinderType type;

	/**
	 * Internal storage of the pointer returned by FindRoute which can be given to BuildRoute.
	 */
	struct Path {
		TileIndex start;
		TileIndex end;
	};

	/**
	 * Build the real route based on begin and end tile.
	 */
	bool BuildRealRoute(TileIndex start, TileIndex end, bool continue_on_error);
};

#endif /* AI_PATHFINDER_HPP */