Skip to content

Commit

Permalink
Clan honor system
Browse files Browse the repository at this point in the history
  • Loading branch information
CM Dev committed Aug 22, 2020
1 parent 2cc8a14 commit 68bdf9f
Show file tree
Hide file tree
Showing 31 changed files with 4,639 additions and 385 deletions.
6 changes: 5 additions & 1 deletion #preprocessor/define/clans.dm
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ var/global/list/clan_ranks_ordered = list(
#define CLAN_ACTION_CLAN_SETDESC "setdesc" // Set description of clan
#define CLAN_ACTION_CLAN_SETHONOR "sethonor" // Set honor of clan
#define CLAN_ACTION_CLAN_DELETE "delete"
#define CLAN_ACTION_CLAN_SETCOLOR "setcolor"

#define CLAN_ACTION_PLAYER_MOVECLAN "moveclan" // Set a player's clan
#define CLAN_ACTION_PLAYER_MODIFYRANK "modifyrank" // Set a player's rank. Resets when moved from clan to Young Blood
Expand All @@ -78,4 +79,7 @@ var/global/list/clan_ranks_ordered = list(
player_modify_ranks = FALSE,\
\
player_move_clans = (clan_info.permissions & CLAN_PERMISSION_ADMIN_MOVE)\
)
)

#define CLAN_SHIP_PUBLIC "Public"
#define CLAN_SHIP_ALMAYER "Almayer"
114 changes: 114 additions & 0 deletions #preprocessor/define/db_defs.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
// MIT License

// Copyright (c) 2020 Neth Iafin

// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:

// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#define DB_ENTITY SSentity_manager.select
#define DB_EKEY SSentity_manager.select_by_key
#define DB_FILTER SSentity_manager.filter_then
#define DB_FILTER_LOCAL SSentity_manager.filter_local
#define DB_META SSentity_manager.tables
#define DB_VIEW SSentity_manager.view_meta
#define WAIT_DB_READY while(!SSentity_manager.ready) {stoplag();}

// MODIFY THESE TO ENABLE OR DISABLE DB ENGINES
#define NDATABASE_BSQL_SUPPORT TRUE
#define NDATABASE_RUSTG_BRSQL_SUPPORT TRUE


#define DB_CAN_VV_GET TRUE
#define DB_LOCK_TIMEOUT 5 SECONDS
#define DB_RECHECK_TIMEOUT 1 SECONDS
#define DB_ENTITY_RECHECK_TIMEOUT 10
#define DB_ENTITY_MAX_CONNECTIONS 30
#define DB_ENTITY_USUAL_CONNECTIONS 20
#define DB_QUERY_RECHECK_TIMEOUT 1 //yes, just 0.1 of a second

#define DB_DEFAULT_ID_FIELD "id"

#define DB_ORDER_BY_DEFAULT 0
#define DB_ORDER_BY_ASC 1
#define DB_ORDER_BY_DESC 2

#define DB_CONNECTION_NOT_CONNECTED 0
#define DB_CONNECTION_BROKEN 1
#define DB_CONNECTION_READY 2
#define DB_CONNECTION_DELETED 3

#define DB_QUERY_STARTED 0
#define DB_QUERY_READING 1
#define DB_QUERY_FINISHED 2
#define DB_QUERY_BROKEN 3

//DB Entity State
//this CANNOT be bit-flag

// We just requested this object from the pool and we didn't specify its ID,
// or we want to change only some fields (not recommended)
// this status is set when you try to select datum from DB
// if we set to this status from Synced, We suspect that outside forces changed this record.
// We want to discard any changes WE made
#define DB_ENTITY_STATE_DETACHED 0
// We properly requested this record, it was received from DB
// In this status we EXPECT that this datum is equivalent to whatever we have in database
#define DB_ENTITY_STATE_SYNCED 1
// We want to add this record to database.
// Record won't be added if datum has ID set to something other than null
#define DB_ENTITY_STATE_ADDED 2
// We want to update the record and move it to the database
#define DB_ENTITY_STATE_UPDATED 3
// We want to delete this record
#define DB_ENTITY_STATE_DELETED 4
// We are reading/writing about this record right now
#define DB_ENTITY_STATE_PROCESSING 5
// Something is wrong
#define DB_ENTITY_STATE_BROKEN 6
// We want to add this record to database.
// But then we want to detach from this record
#define DB_ENTITY_STATE_ADD_DETACH 7
// We are unsure what is this animal. Does it exist? If it does, we add it. In any case, it should be handled somewhere else (in entity manager)
// Since this status is bigger than SYNCED, this means sync() will wait till someone handles it, which is exactly what we need
#define DB_ENTITY_STATE_ADD_OR_SELECT 8
// This is here because Neth is bad
// Basically new item, waiting for it to be read
#define DB_ENTITY_STATE_FRESH 9

//field types
#define DB_FIELDTYPE_INT 1
#define DB_FIELDTYPE_BIGINT 2
#define DB_FIELDTYPE_CHAR 3 // 1 symbol
#define DB_FIELDTYPE_STRING_SMALL 4 // 16 symbols
#define DB_FIELDTYPE_STRING_MEDIUM 5 // 64 symbols
#define DB_FIELDTYPE_STRING_LARGE 6 // 256 symbols
#define DB_FIELDTYPE_STRING_MAX 7 // 4000 symbols
#define DB_FIELDTYPE_DATE 8
#define DB_FIELDTYPE_TEXT 9 // any amount of symbols but really inefficient
#define DB_FIELDTYPE_BLOB 10
#define DB_FIELDTYPE_DECIMAL 11

#define DB_EQUALS 0
#define DB_NOTEQUAL 1
#define DB_GREATER 2
#define DB_LESS 3
#define DB_GREATER_EQUAL 4
#define DB_LESS_EQUAL 5
#define DB_IS 6 // is null
#define DB_ISNOT 7 // is not null
#define DB_IN 8
#define DB_NOTIN 9
5 changes: 3 additions & 2 deletions #preprocessor/define/mob_hud.dm
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#define ORDER_HUD "22" // If humans are affected by orders or not
#define XENO_BANISHED_HUD "23" // indicates that the xeno is banished
#define STATUS_HUD_XENO_CULTIST "24" // Whether they are a xeno cultist or not

#define PRED_CLAN "25"


//data HUD (medhud, sechud) defines
Expand All @@ -40,4 +40,5 @@
#define MOB_HUD_XENO_STATUS 7
#define MOB_HUD_SQUAD 8
#define MOB_HUD_XENO_HOSTILE 9

#define MOB_HUD_PRED_CLAN 10
#define MOB_HUD_SQUAD_OBSERVER 11
3 changes: 1 addition & 2 deletions #preprocessor/define/mode.dm
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ var/global/list/whitelist_hierarchy = list(WHITELIST_NORMAL, WHITELIST_COUNCIL,
#define WHITELIST_YAUTJA 1
#define WHITELIST_YAUTJA_COUNCIL 2
#define WHITELIST_YAUTJA_LEADER 4
#define WHITELIST_YAUTJA_ELDER 8
#define WHITELIST_PREDATOR (WHITELIST_YAUTJA|WHITELIST_YAUTJA_ELDER|WHITELIST_YAUTJA_COUNCIL|WHITELIST_YAUTJA_ELDER)
#define WHITELIST_PREDATOR (WHITELIST_YAUTJA|WHITELIST_YAUTJA_COUNCIL|WHITELIST_YAUTJA_LEADER)

#define WHITELIST_COMMANDER 16
#define WHITELIST_COMMANDER_COUNCIL 32
Expand Down
2 changes: 2 additions & 0 deletions ColonialMarinesALPHA.dme
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "#preprocessor\define\code_events.dm"
#include "#preprocessor\define\combat.dm"
#include "#preprocessor\define\conflict.dm"
#include "#preprocessor\define\db_defs.dm"
#include "#preprocessor\define\defenses.dm"
#include "#preprocessor\define\equipment.dm"
#include "#preprocessor\define\event_system.dm"
Expand Down Expand Up @@ -996,6 +997,7 @@
#include "code\modules\clans\clan.dm"
#include "code\modules\clans\client.dm"
#include "code\modules\clans\rank.dm"
#include "code\modules\clans\ship.dm"
#include "code\modules\client\assets_cache.dm"
#include "code\modules\client\client_defines.dm"
#include "code\modules\client\client_procs.dm"
Expand Down
2 changes: 1 addition & 1 deletion code/_onclick/hud/yautja.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
var/ui_alpha = client.prefs.UI_style_alpha
hud_used = new /datum/hud/human/yautja(src, ui_datum, ui_color, ui_alpha)
else
hud_used = new /datum/hud/human/yautja(src)
hud_used = new /datum/hud/human/yautja(src)
115 changes: 0 additions & 115 deletions code/datums/_ndatabase/include.dm
Original file line number Diff line number Diff line change
@@ -1,118 +1,3 @@
// MIT License

// Copyright (c) 2020 Neth Iafin

// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:

// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#define DB_ENTITY SSentity_manager.select
#define DB_EKEY SSentity_manager.select_by_key
#define DB_FILTER SSentity_manager.filter_then
#define DB_FILTER_LOCAL SSentity_manager.filter_local
#define DB_META SSentity_manager.tables
#define DB_VIEW SSentity_manager.view_meta
#define WAIT_DB_READY while(!SSentity_manager.ready) {stoplag();}

// MODIFY THESE TO ENABLE OR DISABLE DB ENGINES
#define NDATABASE_BSQL_SUPPORT TRUE
#define NDATABASE_RUSTG_BRSQL_SUPPORT TRUE


#define DB_CAN_VV_GET TRUE
#define DB_LOCK_TIMEOUT 5 SECONDS
#define DB_RECHECK_TIMEOUT 1 SECONDS
#define DB_ENTITY_RECHECK_TIMEOUT 10
#define DB_ENTITY_MAX_CONNECTIONS 30
#define DB_ENTITY_USUAL_CONNECTIONS 20
#define DB_QUERY_RECHECK_TIMEOUT 1 //yes, just 0.1 of a second

#define DB_DEFAULT_ID_FIELD "id"

#define DB_ORDER_BY_DEFAULT 0
#define DB_ORDER_BY_ASC 1
#define DB_ORDER_BY_DESC 2

#define DB_CONNECTION_NOT_CONNECTED 0
#define DB_CONNECTION_BROKEN 1
#define DB_CONNECTION_READY 2
#define DB_CONNECTION_DELETED 3

#define DB_QUERY_STARTED 0
#define DB_QUERY_READING 1
#define DB_QUERY_FINISHED 2
#define DB_QUERY_BROKEN 3

//DB Entity State
//this CANNOT be bit-flag

// We just requested this object from the pool and we didn't specify its ID,
// or we want to change only some fields (not recommended)
// this status is set when you try to select datum from DB
// if we set to this status from Synced, We suspect that outside forces changed this record.
// We want to discard any changes WE made
#define DB_ENTITY_STATE_DETACHED 0
// We properly requested this record, it was received from DB
// In this status we EXPECT that this datum is equivalent to whatever we have in database
#define DB_ENTITY_STATE_SYNCED 1
// We want to add this record to database.
// Record won't be added if datum has ID set to something other than null
#define DB_ENTITY_STATE_ADDED 2
// We want to update the record and move it to the database
#define DB_ENTITY_STATE_UPDATED 3
// We want to delete this record
#define DB_ENTITY_STATE_DELETED 4
// We are reading/writing about this record right now
#define DB_ENTITY_STATE_PROCESSING 5
// Something is wrong
#define DB_ENTITY_STATE_BROKEN 6
// We want to add this record to database.
// But then we want to detach from this record
#define DB_ENTITY_STATE_ADD_DETACH 7
// We are unsure what is this animal. Does it exist? If it does, we add it. In any case, it should be handled somewhere else (in entity manager)
// Since this status is bigger than SYNCED, this means sync() will wait till someone handles it, which is exactly what we need
#define DB_ENTITY_STATE_ADD_OR_SELECT 8
// This is here because Neth is bad
// Basically new item, waiting for it to be read
#define DB_ENTITY_STATE_FRESH 9

//field types
#define DB_FIELDTYPE_INT 1
#define DB_FIELDTYPE_BIGINT 2
#define DB_FIELDTYPE_CHAR 3 // 1 symbol
#define DB_FIELDTYPE_STRING_SMALL 4 // 16 symbols
#define DB_FIELDTYPE_STRING_MEDIUM 5 // 64 symbols
#define DB_FIELDTYPE_STRING_LARGE 6 // 256 symbols
#define DB_FIELDTYPE_STRING_MAX 7 // 4000 symbols
#define DB_FIELDTYPE_DATE 8
#define DB_FIELDTYPE_TEXT 9 // any amount of symbols but really inefficient
#define DB_FIELDTYPE_BLOB 10
#define DB_FIELDTYPE_DECIMAL 11

#define DB_EQUALS 0
#define DB_NOTEQUAL 1
#define DB_GREATER 2
#define DB_LESS 3
#define DB_GREATER_EQUAL 4
#define DB_LESS_EQUAL 5
#define DB_IS 6 // is null
#define DB_ISNOT 7 // is not null
#define DB_IN 8
#define DB_NOTIN 9

#include "code/database.dm"

#ifdef NDATABASE_RUSTG_BRSQL_SUPPORT
Expand Down
9 changes: 8 additions & 1 deletion code/datums/entities/clans.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
var/description

var/honor
var/color

BSQL_PROTECT_DATUM(/datum/entity/clan_player)
BSQL_PROTECT_DATUM(/datum/entity/clan)
Expand All @@ -20,7 +21,13 @@ BSQL_PROTECT_DATUM(/datum/entity/clan)
table_name = "clans"
field_types = list("name" = DB_FIELDTYPE_STRING_MEDIUM,
"description" = DB_FIELDTYPE_STRING_MAX,
"honor" = DB_FIELDTYPE_BIGINT)
"honor" = DB_FIELDTYPE_BIGINT,
"color" = DB_FIELDTYPE_STRING_SMALL)

/datum/entity_meta/clan/on_insert(var/datum/entity/clan/player_clan)
player_clan.color = "#FFFFFF"

player_clan.save()

/datum/entity_meta/clan_player
entity_type = /datum/entity/clan_player
Expand Down
25 changes: 22 additions & 3 deletions code/datums/mob_hud.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ var/datum/mob_hud/huds = list(
MOB_HUD_XENO_STATUS = new /datum/mob_hud/xeno(),
MOB_HUD_SQUAD = new /datum/mob_hud/squad(),
MOB_HUD_XENO_HOSTILE = new /datum/mob_hud/xeno_hostile(),
MOB_HUD_PRED_CLAN = new /datum/mob_hud/pred_clan(),
MOB_HUD_SQUAD_OBSERVER = new /datum/mob_hud/squad/observer()
)

/datum/mob_hud
Expand Down Expand Up @@ -133,6 +135,8 @@ var/datum/mob_hud/huds = list(
/datum/mob_hud/xeno_hostile
hud_icons = list(XENO_HOSTILE_ACID, XENO_HOSTILE_SLOW, XENO_HOSTILE_TAG, XENO_HOSTILE_FREEZE)

/datum/mob_hud/pred_clan
hud_icons = list(PRED_CLAN)

//Security

Expand All @@ -148,6 +152,8 @@ var/datum/mob_hud/huds = list(
/datum/mob_hud/squad
hud_icons = list(SQUAD_HUD, ORDER_HUD)

/datum/mob_hud/squad/observer
hud_icons = list(SQUAD_HUD, ORDER_HUD, PRED_CLAN)



Expand Down Expand Up @@ -370,9 +376,6 @@ var/datum/mob_hud/huds = list(
holder2.icon_state = "hudhealthy"
holder3.icon_state = ""




//xeno status HUD

/mob/living/carbon/Xenomorph/proc/hud_set_plasma()
Expand Down Expand Up @@ -612,6 +615,22 @@ var/datum/mob_hud/huds = list(
holder.overlays += image('icons/mob/hud/hud.dmi',src, "hudmarinesquad[marine_rk]")
if(border_rk)
holder.overlays += image('icons/mob/hud/hud.dmi',src, "hudmarineborder[border_rk]")
hud_list[SQUAD_HUD] = holder

/mob/living/carbon/human/yautja/hud_set_squad()
set waitfor = FALSE

var/image/holder = hud_list[PRED_CLAN]

holder.icon_state = "predhud"

if(client && client.clan_info && client.clan_info.clan_id)
var/datum/entity/clan/player_clan = GET_CLAN(client.clan_info.clan_id)
player_clan.sync()

holder.color = player_clan.color

hud_list[PRED_CLAN] = holder

/mob/proc/hud_set_order()
return
Expand Down
Loading

0 comments on commit 68bdf9f

Please sign in to comment.