ddstats/src/database/map.rs

73 lines
2.2 KiB
Rust

use mysql_common::{chrono::NaiveDateTime, frunk::HList};
use rocket::serde::{Serialize, Deserialize};
pub type MapRow = HList!(String, String, i8, i8, String, NaiveDateTime, String, i32, i32, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool);
// Different tile types and whether they appear in the map.
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(crate = "rocket::serde")]
pub struct MapTileData {
pub death: bool,
pub through: bool,
pub jump: bool,
pub dfreeze: bool,
pub ehook_start: bool,
pub hit_end: bool,
pub solo_start: bool,
pub tele_gun: bool,
pub tele_grenade: bool,
pub tele_laser: bool,
pub npc_start: bool,
pub super_start: bool,
pub jetpack_start: bool,
pub walljump: bool,
pub nph_start: bool,
pub weapon_shotgun: bool,
pub weapon_grenade: bool,
pub powerup_ninja: bool,
pub weapon_rifle: bool,
pub laser_stop: bool,
pub crazy_shotgun: bool,
pub dragger: bool,
pub door: bool,
pub switch_timed: bool,
pub switch: bool,
pub stop: bool,
pub through_all: bool,
pub tune: bool,
pub oldlaser: bool,
pub teleinevil: bool,
pub telein: bool,
pub telecheck: bool,
pub teleinweapon: bool,
pub teleinhook: bool,
pub checkpoint_first: bool,
pub bonus: bool,
pub boost: bool,
pub plasmaf: bool,
pub plasmae: bool,
pub plasmau: bool
}
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(crate = "rocket::serde")]
pub struct Map {
pub name: String,
pub server: String,
pub points: i8,
pub stars: i8,
pub mapper: String,
pub timestamp: NaiveDateTime,
pub width: i32,
pub height: i32,
pub tile_data: MapTileData
}
/*
IMPORTANT: For this to work the following SQL query must be executed:
```SQL
UPDATE record_maps SET Timestamp='1970-01-01 01:01:01' WHERE Timestamp='1990-01-01 00:00:00';
```
Else the reads on `record_maps` will fail whenever the timestamp is '0000-00-00 00:00:00'!
TODO: Fix this server-side.
*/