You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
96 lines
1.9 KiB
96 lines
1.9 KiB
|
|
#ifndef _RAILWAY_H_
|
|
#define _RAILWAY_H_
|
|
|
|
#include "modelbahn.h"
|
|
#include "server.h"
|
|
|
|
enum {
|
|
RAILWAY_NOTHING = 0,
|
|
RAILWAY_NORMAL,
|
|
RAILWAY_CROSSING,
|
|
RAILWAY_TURNOUT,
|
|
RAILWAY_SENSOR,
|
|
RAILWAY_CONNECTOR,
|
|
RAILWAY_BUTTON, // just a simple button on the track to press
|
|
RAILWAY_TEXT,
|
|
RAILWAY_BLOCK,
|
|
|
|
RAILWAY_MAX
|
|
};
|
|
|
|
|
|
#define RAILWAYS_MIN_WIDTH 40
|
|
#define RAILWAYS_MIN_HEIGHT 25
|
|
#define RAILWAYS_MAX_WIDTH 500
|
|
#define RAILWAYS_MAX_HEIGHT 500
|
|
|
|
|
|
// direktion
|
|
//
|
|
// +---+ +---+ +---+ +---+
|
|
// | | | | | | | |/ |
|
|
// 0| | 1| | | 2|---| 3| |
|
|
// | | | | | | | | |
|
|
// +---+ +---+ +---+ +---+
|
|
//
|
|
// +---+ +---+ +---+ +---+
|
|
// | \| | | | | | |
|
|
// 4| | 5| | 6| | 7| |
|
|
// | | | /| |\ | | |
|
|
// +---+ +---+ +---+ +---+
|
|
//
|
|
|
|
|
|
struct s_Railway {
|
|
int type;
|
|
int x;
|
|
int y;
|
|
int dir;
|
|
int altdir; // turnout or crossing
|
|
int maxspeed;
|
|
int flags; // not defined yet
|
|
char name[REFERENCENAME_LEN]; // reference name
|
|
} typedef Railway;
|
|
|
|
|
|
class Railways {
|
|
private:
|
|
Railway *railways;
|
|
|
|
int width;
|
|
int height;
|
|
int changed;
|
|
|
|
pthread_mutex_t mtx;
|
|
int Lock();
|
|
int UnLock();
|
|
int GetRIdx(int x, int y);
|
|
JSONParse _GetJSONRailway(int x, int y);
|
|
void _New (int w, int h);
|
|
public:
|
|
|
|
Railways();
|
|
~Railways();
|
|
|
|
void New (int w, int h);
|
|
void SetSize (int w, int h);
|
|
Railway Get(int x, int y);
|
|
Railways* GetBlock(int x, int y, int w, int h);
|
|
int Set(Railway *rw);
|
|
int SetBlock(Railway *rw, int cnt);
|
|
int GetHeight () {return height;};
|
|
int GetWidth () {return width;};
|
|
int IsChanged() { return changed; };
|
|
void ClearChanged() { changed = 0; };
|
|
int Change(Railway *rw);
|
|
|
|
Railway RailwayGet(int x, int y) {return railways[GetRIdx(x, y)];};
|
|
JSONParse GetJSONRailway(int x, int y);
|
|
JSONParse GetJSONTrack();
|
|
void GetJSONAll(JSONParse *json);
|
|
Railway GetRailwayFromJSON(JSONParse *j);
|
|
};
|
|
|
|
#endif
|