Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.
Merged
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
30 changes: 27 additions & 3 deletions SQL/database_changelog.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,39 @@
Any time you make a change to the schema files, remember to increment the database schema version. Generally increment the minor number, major should be reserved for significant changes to the schema. Both values go up to 255.

The latest database version is 5.2; The query to update the schema revision table is:
The latest database version is 5.3; The query to update the schema revision table is:

INSERT INTO `schema_revision` (`major`, `minor`) VALUES (5, 2);
INSERT INTO `schema_revision` (`major`, `minor`) VALUES (5, 3);
or
INSERT INTO `SS13_schema_revision` (`major`, `minor`) VALUES (5, 2);
INSERT INTO `SS13_schema_revision` (`major`, `minor`) VALUES (5, 3);

In any query remember to add a prefix to the table names if you use one.

----------------------------------------------------

version 5.3 10 Dec 2019, by Nichlas0010

Added two tables for achievements, one for the metadata and one for storing achieved achievements, as well as a misc table which is essentially just a glorified assoc list

CREATE TABLE `achievements` (
`name` VARCHAR(32) NOT NULL,
`id` INT UNSIGNED NOT NULL,
`descr` VARCHAR(2048) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB;

CREATE TABLE `earned_achievements` (
`ckey` VARCHAR(32) NOT NULL,
`id` INT UNSIGNED NOT NULL
) ENGINE=InnoDB;

CREATE TABLE `misc` (
`key` VARCHAR(32) NOT NULL,
`value` VARCHAR(2048) NOT NULL,
PRIMARY KEY (`key`)
) ENGINE=InnoDB;

----------------------------------------------------

Version 5.2, 28 Aug 2019, by AffectedArc07/TheGamer01

Added a field to the `player` table to track ckey and discord ID relationships
Expand Down
10 changes: 10 additions & 0 deletions SQL/tgstation_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,16 @@ CREATE TABLE `earned_achievements` (
`id` INT UNSIGNED NOT NULL
) ENGINE=InnoDB;

--
-- Table structure for table `achievements`
--
DROP TABLE IF EXISTS `misc`;
CREATE TABLE `misc` (
`key` VARCHAR(32) NOT NULL,
`value` VARCHAR(2048) NOT NULL,
PRIMARY KEY (`key`)
) ENGINE=InnoDB;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
Expand Down
10 changes: 10 additions & 0 deletions SQL/tgstation_schema_prefixed.sql
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,16 @@ CREATE TABLE `SS13_earned_achievements` (
`id` INT UNSIGNED NOT NULL
) ENGINE=InnoDB;

--
-- Table structure for table `achievements`
--
DROP TABLE IF EXISTS `SS13_misc`;
CREATE TABLE `SS13_misc` (
`key` VARCHAR(32) NOT NULL,
`value` VARCHAR(2048) NOT NULL,
PRIMARY KEY (`key`)
) ENGINE=InnoDB;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
Expand Down
25 changes: 25 additions & 0 deletions code/__HELPERS/roundend.dm
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@
//Set news report and mode result
mode.set_round_result()

// Check whether the cargo king achievement was achieved
cargoking()

send2irc("Server", "Round just ended.")

if(length(CONFIG_GET(keyed_list/cross_server)))
Expand Down Expand Up @@ -590,3 +593,25 @@
return
qdel(query_update_everything_ranks)
qdel(query_check_everything_ranks)

/datum/controller/subsystem/ticker/proc/cargoking()
var/datum/achievement/cargoking/CK = SSachievements.get_achievement(/datum/achievement/cargoking)
var/cargoking = FALSE
var/ducatduke = FALSE
if(SSshuttle.points > 1000000)//Why is the cargo budget on SSshuttle instead of SSeconomy :thinking:
ducatduke = TRUE
if(SSshuttle.points > CK.amount)
cargoking = TRUE
var/hasQM = FALSE //we only wanna update the record if there's a QM
for(var/mob/M in GLOB.player_list)
if(M.mind && M.mind.assigned_role && M.mind.assigned_role == "Quartermaster")
if(ducatduke)
SSachievements.unlock_achievement(/datum/achievement/ducatduke, M.client)
if(cargoking)
SSachievements.unlock_achievement(/datum/achievement/cargoking, M.client)
hasQM = TRUE //there might be more than one QM, so we do the DB stuff outside of the loop
if(hasQM && cargoking)
var/datum/DBQuery/Q = SSdbcore.New("UPDATE [format_table_name("misc")] SET value = '[SSshuttle.points]' WHERE key = 'cargorecord'")
Q.Execute()
qdel(Q)

32 changes: 25 additions & 7 deletions code/datums/achievements/achievements.dm
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,6 @@
desc = "Kill yourself using the nuclear authentication disk"
id = 7
hidden = TRUE


/datum/achievement/likearecord
name = "You spin me round"
desc = "Use the surgical drill to spin right round like a record baby"
id = 21
hidden = TRUE

/datum/achievement/badass
name = "Badass Syndie"
Expand Down Expand Up @@ -112,4 +105,29 @@
desc = "As a signal technician create a script that makes poly LOUD"
id = 19
hidden = TRUE

/datum/achievement/cargoking
name = "King of Credits"
desc = "As the QM, beat the current record of cargo credits: " //theoretically, if someone manages to get to an amount that's larger than 1992 digits, this'd break DB things
id = 20
var/amount = 0

/datum/achievement/cargoking/New()
.=..()
var/datum/DBQuery/Q = SSdbcore.NewQuery("SELECT value FROM [format_table_name("misc")] WHERE key = 'cargorecord'")
Q.Execute()
if(Q.item.len)
amount = Q.item[1]
qdel(Q)
desc += "[amount]"

/datum/achievement/likearecord
name = "You spin me round"
desc = "Use the surgical drill to spin right round like a record baby"
id = 21
hidden = TRUE

/datum/achievement/ducatduke
name = "Duke of Ducats"
desc = "As the QM, have a million cargo credits by the end of the round" //Cargoking-junior
id = 22