-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Watermelon914
authored and
Neth Iafin
committed
Sep 21, 2020
1 parent
338239f
commit b875896
Showing
17 changed files
with
147 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
var/datum/subsystem/playtime/SSplaytime | ||
|
||
|
||
/datum/subsystem/playtime | ||
name = "Playtime" | ||
wait = 1 MINUTES | ||
priority = SS_PRIORITY_PLAYTIME | ||
init_order = SS_INIT_PLAYTIME | ||
flags = SS_NO_INIT | SS_KEEP_TIMING | ||
|
||
var/list/currentrun = list() | ||
|
||
/datum/subsystem/playtime/New() | ||
NEW_SS_GLOBAL(SSplaytime) | ||
|
||
/datum/subsystem/playtime/fire(resumed = FALSE) | ||
if (!resumed) | ||
src.currentrun = clients.Copy() | ||
|
||
var/list/currentrun = src.currentrun | ||
|
||
while (currentrun.len) | ||
var/client/C = currentrun[currentrun.len] | ||
currentrun.len-- | ||
|
||
var/mob/M = C.mob | ||
var/datum/entity/player/P = C.player_data | ||
|
||
if(!M || !M.job || M.stat == DEAD || M.statistic_exempt || !P || !P.playtime_loaded) | ||
if(MC_TICK_CHECK) | ||
return | ||
continue | ||
|
||
var/datum/entity/player_time/PTime = LAZYACCESS(P.playtimes, M.job) | ||
|
||
if(!PTime) | ||
PTime = DB_ENTITY(/datum/entity/player_time) | ||
PTime.player_id = P.id | ||
PTime.role_id = M.job | ||
LAZYSET(P.playtimes, M.job, PTime) | ||
|
||
PTime.total_minutes += 1 | ||
PTime.save() | ||
|
||
if (MC_TICK_CHECK) | ||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/datum/entity/player_time | ||
var/player_id | ||
var/role_id | ||
var/total_minutes | ||
|
||
BSQL_PROTECT_DATUM(/datum/entity/player_time) | ||
|
||
/datum/entity_meta/player_time | ||
entity_type = /datum/entity/player_time | ||
table_name = "player_playtime" | ||
field_types = list( | ||
"player_id" = DB_FIELDTYPE_BIGINT, | ||
"role_id" = DB_FIELDTYPE_STRING_LARGE, | ||
"total_minutes" = DB_FIELDTYPE_BIGINT | ||
) | ||
|
||
/datum/entity_meta/player_time/on_insert(var/datum/entity/player_time/player) | ||
player.total_minutes = 0 | ||
|
||
/datum/entity_link/player_to_time | ||
parent_entity = /datum/entity/player | ||
child_entity = /datum/entity/player_time | ||
child_field = "player_id" | ||
|
||
parent_name = "player" | ||
child_name = "player_times" | ||
|
||
#define MINUTES_TO_DECISECOND *600 // Converting to decisecond makes it easier to do in calculations | ||
|
||
#define get_job_playtime(client, job) (client.player_data? LAZYACCESS(client.player_data.playtimes, job)? client.player_data.playtimes[job].total_minutes MINUTES_TO_DECISECOND : 0 : 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.