Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Characters v2: staging #6801

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 64 additions & 7 deletions SQL/database_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
* PRESERVE ANY vr_'s! We need to replace those tables and features at some point, that's how we konw.
**/

-- core --
/**************************************************************************************************
Database Backend
**************************************************************************************************/

--
-- Table structure for table `schema_revision`
Expand All @@ -18,7 +20,55 @@ CREATE TABLE IF NOT EXISTS `%_PREFIX_%schema_revision` (
PRIMARY KEY (`major`, `minor`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- persistence --
/**************************************************************************************************
Character Tables
**************************************************************************************************/

CREATE TABLE IF NOT EXISTS `%_PREFIX_%characters` (
`id` INT(24) NOT NULL AUTO INCREMENT,

) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

CREATE TABLE IF NOT EXISTS `%_PREFIX_%character_records` (
`id` INT(24) NOT NULL AUTO INCREMENT,
`flags` INT(24) NOT NULL DEFAULT 0,
`data` MEDIUMTEXT NOT NULL DEFAULT '{}',
`r_timestamp` DATETIME NULL,
`r_location` VARCHAR(512) NULL,
`r_label` VARCHAR(256) NULL,
`r_content_type` VARCHAR(64) NULL,
`r_content` TEXT NULL,
`r_author_character_id` INT(24) NULL,
CONSTRAINT `r_author_character_id` FOREIGN KEY (`r_author_character_id`)
REFERENCES `%_PREFIX_%characters` (`id`)
ON DELETE NULL
ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

/**
* 'changes' is a JSON array of strings.
*/
CREATE TABLE IF NOT EXISTS `%_PREFIX_%character_record_logs` (
`id` INT(24) NOT NULL AUTO INCREMENT,
`record_id` INT(24) NOT NULL,
`timestamp` DATETIME NOT NULL DEFAULT Now(),
`player_id` INT(24) NULL,
`character_id` INT(24) NULL,
`changes` MEDIUMTEXT,
PRIMARY KEY(`id`),
CONSTRAINT `audit_player_id` FOREIGN KEY (`audit_character_id`)
REFERENCES `%_PREFIX_%player` (`id`)
ON DELETE NULL
ON UPDATE CASCADE,
CONSTRAINT `audit_character_id` FOREIGN KEY (`audit_character_id`)
REFERENCES `%_PREFIX_%characters` (`id`)
ON DELETE NULL
ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

/**************************************************************************************************
World Persistence Tables
**************************************************************************************************/

-- SSpersistence modules/bulk_entity
CREATE TABLE IF NOT EXISTS `%_PREFIX_%persistence_bulk_entity` (
Expand Down Expand Up @@ -97,7 +147,9 @@ CREATE TABLE IF NOT EXISTS `%_PREFIX_%persistence_string_kv` (
PRIMARY KEY(`key`, `group`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- photography --
/**************************************************************************************************
Photography Tables
**************************************************************************************************/

-- picture table --
-- used to store data about pictures --
Expand Down Expand Up @@ -128,7 +180,9 @@ CREATE TABLE IF NOT EXISTS `%_PREFIX_%photographs` (
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- Players --
/**************************************************************************************************
Player Tables
**************************************************************************************************/

-- Player lookup table --
-- Used to look up player ID from ckey, as well as --
Expand Down Expand Up @@ -157,7 +211,9 @@ CREATE TABLE IF NOT EXISTS `%_PREFIX_%player` (
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- Playtime / JEXP --
/**************************************************************************************************
Players - Playtime Tracking
**************************************************************************************************/

-- Role Time Table - Master --
-- Stores total role time. --
Expand Down Expand Up @@ -195,8 +251,9 @@ END
$$
DELIMITER ;


-- Preferences --
/**************************************************************************************************
Players - Game Preferences
**************************************************************************************************/

-- Stores game preferences --
CREATE TABLE IF NOT EXISTS `%_PREFIX_%game_preferences` (
Expand Down
47 changes: 40 additions & 7 deletions citadel.dme
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@
#include "code\__DEFINES\atmospherics\machinery\scrubber.dm"
#include "code\__DEFINES\atmospherics\machinery\vent.dm"
#include "code\__DEFINES\cargo\supply.dm"
#include "code\__DEFINES\characters\character.dm"
#include "code\__DEFINES\characters\character_record.dm"
#include "code\__DEFINES\client\game_preferences.dm"
#include "code\__DEFINES\client\player_flags.dm"
#include "code\__DEFINES\client\playtime.dm"
Expand Down Expand Up @@ -603,6 +605,7 @@
#include "code\controllers\subsystem\characters\backgrounds.dm"
#include "code\controllers\subsystem\characters\character_species.dm"
#include "code\controllers\subsystem\characters\languages.dm"
#include "code\controllers\subsystem\characters\records.dm"
#include "code\controllers\subsystem\characters\species.dm"
#include "code\controllers\subsystem\dbcore\_dbcore.dm"
#include "code\controllers\subsystem\dbcore\query.dm"
Expand Down Expand Up @@ -635,9 +638,9 @@
#include "code\controllers\subsystem\mapping\spatial_helpers\loc.dm"
#include "code\controllers\subsystem\mapping\spatial_helpers\stack.dm"
#include "code\controllers\subsystem\mapping\spatial_helpers\step.dm"
#include "code\controllers\subsystem\persistence\bunker.dm"
#include "code\controllers\subsystem\persistence\_persistence.dm"
#include "code\controllers\subsystem\persistence\entity_operations.dm"
#include "code\controllers\subsystem\persistence\persistence.dm"
#include "code\controllers\subsystem\persistence\panic_bunker.dm"
#include "code\controllers\subsystem\persistence\prototype_lookup.dm"
#include "code\controllers\subsystem\persistence\world.dm"
#include "code\controllers\subsystem\persistence\modules\bulk_entity.dm"
Expand Down Expand Up @@ -2302,6 +2305,15 @@
#include "code\modules\asset_cache\assets\tgui.dm"
#include "code\modules\asset_cache\assets\vv.dm"
#include "code\modules\asset_cache\assets\artwork\crayons.dm"
#include "code\modules\asset_cache\assets\characters\json\character_appearance.dm"
#include "code\modules\asset_cache\assets\characters\json\character_background.dm"
#include "code\modules\asset_cache\assets\characters\json\character_loadout.dm"
#include "code\modules\asset_cache\assets\characters\json\character_setup.dm"
#include "code\modules\asset_cache\assets\characters\spritesheet\bodyset_markings.dm"
#include "code\modules\asset_cache\assets\characters\spritesheet\bodysets.dm"
#include "code\modules\asset_cache\assets\characters\spritesheet\loadout.dm"
#include "code\modules\asset_cache\assets\characters\spritesheet\species.dm"
#include "code\modules\asset_cache\assets\characters\spritesheet\sprite_accessories.dm"
#include "code\modules\asset_cache\assets\chemistry\bottles.dm"
#include "code\modules\asset_cache\assets\chemistry\patches.dm"
#include "code\modules\asset_cache\assets\chemistry\pills.dm"
Expand Down Expand Up @@ -2422,6 +2434,7 @@
#include "code\modules\blob2\overmind\overmind.dm"
#include "code\modules\blob2\overmind\powers.dm"
#include "code\modules\blob2\overmind\types.dm"
#include "code\modules\bodysets\bodyset_marking_descriptor.dm"
#include "code\modules\bodysets\sprite_accessories.dm"
#include "code\modules\bodysets\organic\akula.dm"
#include "code\modules\bodysets\organic\apidean.dm"
Expand Down Expand Up @@ -2456,6 +2469,24 @@
#include "code\modules\catalogue\cataloguer.dm"
#include "code\modules\catalogue\cataloguer_visuals.dm"
#include "code\modules\catalogue\cataloguer_vr.dm"
#include "code\modules\characters\character\character.dm"
#include "code\modules\characters\character\character_appearance.dm"
#include "code\modules\characters\character\character_background.dm"
#include "code\modules\characters\character\character_bodypart_appearance.dm"
#include "code\modules\characters\character\character_bodypart_physiology.dm"
#include "code\modules\characters\character\character_inventory.dm"
#include "code\modules\characters\character\character_loadout.dm"
#include "code\modules\characters\character\character_physiology.dm"
#include "code\modules\characters\character\character_record.dm"
#include "code\modules\characters\character\character_skills.dm"
#include "code\modules\characters\character\character_status.dm"
#include "code\modules\characters\character\character_record\employment.dm"
#include "code\modules\characters\character\character_record\incident.dm"
#include "code\modules\characters\character\character_record\intelligence.dm"
#include "code\modules\characters\character\character_record\medical.dm"
#include "code\modules\characters\character_setup\character_setup.dm"
#include "code\modules\characters\character_shapeshift\character_shapeshift.dm"
#include "code\modules\characters\character_shapeshift\character_shapeshift_holder.dm"
#include "code\modules\client\client-admin.dm"
#include "code\modules\client\client.dm"
#include "code\modules\client\client_procs.dm"
Expand Down Expand Up @@ -3195,6 +3226,7 @@
#include "code\modules\loadout\loadout_general.dm"
#include "code\modules\loadout\loadout_gloves.dm"
#include "code\modules\loadout\loadout_head.dm"
#include "code\modules\loadout\loadout_item_descriptor.dm"
#include "code\modules\loadout\loadout_mask.dm"
#include "code\modules\loadout\loadout_role_restricted.dm"
#include "code\modules\loadout\loadout_seasonal.dm"
Expand Down Expand Up @@ -3538,13 +3570,13 @@
#include "code\modules\mob\_modifiers\traits.dm"
#include "code\modules\mob\_modifiers\traits_phobias.dm"
#include "code\modules\mob\_modifiers\unholy.dm"
#include "code\modules\mob\characteristics\characteristic_preset.dm"
#include "code\modules\mob\characteristics\characteristic_skill.dm"
#include "code\modules\mob\characteristics\characteristic_stat.dm"
#include "code\modules\mob\characteristics\characteristic_talent.dm"
#include "code\modules\mob\characteristics\characteristics_holder.dm"
#include "code\modules\mob\characteristics\helpers.dm"
#include "code\modules\mob\characteristics\holder.dm"
#include "code\modules\mob\characteristics\mob.dm"
#include "code\modules\mob\characteristics\presets.dm"
#include "code\modules\mob\characteristics\skill.dm"
#include "code\modules\mob\characteristics\stat.dm"
#include "code\modules\mob\characteristics\talent.dm"
#include "code\modules\mob\characteristics\ui.dm"
#include "code\modules\mob\characteristics\skills\engineering.dm"
#include "code\modules\mob\characteristics\skills\logistics.dm"
Expand Down Expand Up @@ -4828,6 +4860,7 @@
#include "code\modules\sprite_accessories\ears.dm"
#include "code\modules\sprite_accessories\hair.dm"
#include "code\modules\sprite_accessories\sprite_accessory.dm"
#include "code\modules\sprite_accessories\sprite_accessory_descriptor.dm"
#include "code\modules\sprite_accessories\tail.dm"
#include "code\modules\sprite_accessories\wings.dm"
#include "code\modules\sprite_accessories\ears\antenna.dm"
Expand Down
21 changes: 21 additions & 0 deletions code/__DEFINES/characters/character.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//* This file is explicitly licensed under the MIT license. *//
//* Copyright (c) 2024 Citadel Station Developers *//

//* appearance *//

/// max appearance slots soemone is allowed to have
#define CHARATER_MAX_APPEARANCE_SLOTS 32

//* loadout *//

/// max loadout sets someone is allowed to have
#define CHARACTER_MAX_LOADOUT_SLOTS 32
/// max loadout items in a set
#define CHARACTER_MAX_LOADOUT_ITEMS 32

//* role priorities *//

#define CHARACTER_ROLE_PRIORITY_NEVER 0
#define CHARACTER_ROLE_PRIORITY_LOW 1
#define CHARACTER_ROLE_PRIORITY_MEDIUM 2
#define CHARACTER_ROLE_PRIORITY_HIGH 3
30 changes: 30 additions & 0 deletions code/__DEFINES/characters/character_record.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//* This file is explicitly licensed under the MIT license. *//
//* Copyright (c) 2024 Citadel Station Developers *//

//* /datum/character_record character_record_flags *//

/// ICly sealed
///
/// * admins can do this
/// * certain IC sources may be able to do this in the future
#define CHARACTER_RECORD_FLAG_SEALED (1<<0)
/// OOCly deleted
///
/// * only admins can do this
#define CHARACTER_RECORD_FLAG_DELETED (1<<1)

//* /datum/character_record character_record_type *//

/// incident records, used by security and command staff of one's own faction, usually
#define CHARACTER_RECORD_TYPE_INCIDENT "incident"
/// medical record, used by medical staff of one's own faction, usually
#define CHARACTER_RECORD_TYPE_MEDICAL "medical"
/// employment record, used by leaders or heads of departments of one's own faction, usually
#define CHARACTER_RECORD_TYPE_EMPLOYMENT "employment"
/// exploitable info, used by factions hostile to one's self, usually
#define CHARACTER_RECORD_TYPE_INTELLIGENCE "intelligence"

//* /datum/character_record r_content_type's *//

/// text
#define CHARACTER_RECORD_CONTENT_TYPE_PLAINTEXT "text"
13 changes: 12 additions & 1 deletion code/controllers/subsystem/characters/_characters.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//* This file is explicitly licensed under the MIT license. *//
//* Copyright (c) 2023 Citadel Station developers. *//
//* Copyright (c) 2024 Citadel Station Developers *//

// todo: re-review this file; ensure generation / ACID is being enforced.

/**
* Manages character setup, character saving, loading,
Expand All @@ -21,6 +23,15 @@ SUBSYSTEM_DEF(characters)

var/list/save_queue = list()

//* Records *//

/// record datums by associative string id
///
/// * used as a cache
var/list/character_record_cache
/// max cached record datums
var/character_record_cache_limit = 200

/datum/controller/subsystem/characters/Initialize()
rebuild_caches()
for(var/ckey in GLOB.preferences_datums)
Expand Down
28 changes: 28 additions & 0 deletions code/controllers/subsystem/characters/records.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//* This file is explicitly licensed under the MIT license. *//
//* Copyright (c) 2024 Citadel Station Developers *//

/**
* Fetches a single character record
*/
/datum/controller/subsystem/characters/proc/fetch_character_record(id) as /datum/character_record

/**
* Stores a character record
*/
/datum/controller/subsystem/characters/proc/store_character_record(datum/character_record/record)

/**
* Gets records of a given type for a character.
*
* * character_id - the character ID to query
* * record_type - the record type to return
* * page - which page to retrieve; defaults to 1.
* * limit - how many to return per page. This is an utter suggestion to this proc; the subsystem reserves the right to ignore your request.
* * page_total_pointer - if provided, this pointer will be set to how many pages there are at the current limit
* * limit_count_pointer - if provided, this pointer will be set to the limit being used.
*
* @return list(record datum, record datum, ...)
*/
/datum/controller/subsystem/characters/proc/query_character_records(character_id, record_type, page) as /list

#warn impl all

Check warning on line 28 in code/controllers/subsystem/characters/records.dm

View workflow job for this annotation

GitHub Actions / Run Linters

#warn impl all
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ SUBSYSTEM_DEF(persistence)
init_order = INIT_ORDER_PERSISTENCE
subsystem_flags = SS_NO_FIRE

//* World *//

/// world already loaded?
var/static/world_loaded = FALSE
/// world saved how many times?
Expand All @@ -18,14 +20,16 @@ SUBSYSTEM_DEF(persistence)
// todo: interface on subsystem panel
var/static/world_non_canon = FALSE

//* Prototype Lookup *//

/// prototype id to typepath
var/list/prototype_id_to_path

/datum/controller/subsystem/persistence/Initialize()
/// build prototype lookup list
build_prototype_id_lookup()

LoadPersistence()
/// load panic bunker bypass
load_panic_bunker()

// todo: should this be here? save_the_world is in ticker.
if(CONFIG_GET(flag/persistence))
Expand All @@ -34,21 +38,10 @@ SUBSYSTEM_DEF(persistence)
return ..()

/datum/controller/subsystem/persistence/Shutdown()
SavePersistence()
/// save panic bunker bypass
save_panic_bunker()
return ..()

/**
* Loads all persistent information from disk.
*/
/datum/controller/subsystem/persistence/proc/LoadPersistence()
LoadPanicBunker()

/**
* Saves all persistent information to disk.
*/
/datum/controller/subsystem/persistence/proc/SavePersistence()
SavePanicBunker()

//* ID Mapping *//

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// todo: re-review this file; ensure generation / ACID is being enforced.

/**
* somewhat expensive
Expand Down
Loading
Loading