Skip to content

Commit

Permalink
ChatAdditions.inc: get seconds const from time.inc (#285)
Browse files Browse the repository at this point in the history
Fix #276
  • Loading branch information
Nord1cWarr1or committed Mar 4, 2023
1 parent 5f27eb5 commit df22f3a
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions cstrike/addons/amxmodx/scripting/include/ChatAdditions.inc
Expand Up @@ -19,6 +19,10 @@
#define CA_VERSION "%CA_VERSION%"
#endif

#if !defined _time_included
#include <time>
#endif

const CA_MAX_MESSAGE_SIZE = 188

/**
Expand Down Expand Up @@ -62,13 +66,6 @@ new stock const BASE_CHAT_TRIGGERS[][] = { /* "", */"/", "\", "!", "." };


stock parseTime(const value[]) {
const _SECONDS_IN_MINUTE = 60;
const _SECONDS_IN_HOUR = 3600;
const _SECONDS_IN_DAY = 86400;
const _SECONDS_IN_WEEK = 604800;
const _SECONDS_IN_MONTH = _SECONDS_IN_DAY * 31;
const _SECONDS_IN_YEAR = _SECONDS_IN_MONTH * 12;

new t, k;
for (new i; value[i] != EOS; i++) {
switch (value[i]) {
Expand All @@ -77,32 +74,32 @@ stock parseTime(const value[]) {
}

case 'i': {
k += t * _SECONDS_IN_MINUTE;
k += t * SECONDS_IN_MINUTE;
t = 0;
}

case 'h': {
k += t * _SECONDS_IN_HOUR;
k += t * SECONDS_IN_HOUR;
t = 0;
}

case 'd': {
k += t * _SECONDS_IN_DAY;
k += t * SECONDS_IN_DAY;
t = 0;
}

case 'w': {
k += t * _SECONDS_IN_WEEK;
k += t * SECONDS_IN_WEEK;
t = 0;
}

case 'm': {
k += t * _SECONDS_IN_MONTH;
k += t * SECONDS_IN_MONTH;
t = 0;
}

case 'y': {
k += t * _SECONDS_IN_YEAR;
k += t * SECONDS_IN_YEAR;
t = 0;
}

Expand Down

0 comments on commit df22f3a

Please sign in to comment.