123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- #define BUILDING_OPENDOORS
- #include <string.h>
- #include <ctype.h>
- #include <stddef.h>
- #include <stdlib.h>
- #include <time.h>
- #include <stdio.h>
- #include "OpenDoor.h"
- #include "ODCore.h"
- #include "ODGen.h"
- #include "ODStat.h"
- #include "ODKrnl.h"
- char szStatusText[80];
- void ODStatAddKey(WORD wKeyCode)
- {
- if(od_control.od_num_keys < 16)
- od_control.od_hot_key[od_control.od_num_keys++] = wKeyCode;
- }
- void ODStatRemoveKey(WORD wKeyCode)
- {
- INT nCount;
- for(nCount = 0; nCount < od_control.od_num_keys; ++nCount)
- if((WORD)od_control.od_hot_key[nCount] == wKeyCode)
- {
- if(nCount != od_control.od_num_keys - 1)
- {
- od_control.od_hot_key[nCount] =
- od_control.od_hot_key[od_control.od_num_keys-1];
- }
- --od_control.od_num_keys;
- return;
- }
- }
- void ODStatGetUserAge(char *pszAge)
- {
- INT nAge;
- INT n;
- time_t Time;
- struct tm *TimeBlock;
- if(od_control.od_info_type==RA2EXITINFO || od_control.od_info_type==DOORSYS_WILDCAT)
- {
- nAge = atoi(od_control.user_birthday) - 1;
- if(strlen(od_control.user_birthday) == 8 && nAge <= 11)
- {
- if(od_control.user_birthday[6] >= '0'
- && od_control.user_birthday[6] <= '9'
- && od_control.user_birthday[7] >= '0'
- && od_control.user_birthday[7] <= '9')
- {
- if(od_control.user_birthday[3] >= '0'
- && od_control.user_birthday[3] <= '3'
- && od_control.user_birthday[4] >= '0'
- && od_control.user_birthday[4] <= '9')
- {
- Time = time(NULL);
- TimeBlock = localtime(&Time);
- n = (TimeBlock->tm_year % 100)
- - atoi((char *)od_control.user_birthday + 6);
- if(n < 0) nAge = n + 100; else nAge = n;
- n = atoi(od_control.user_birthday) - 1;
- if(TimeBlock->tm_mon < n)
- --nAge;
- else if(TimeBlock->tm_mon == n)
- {
- n=atoi((char *)od_control.user_birthday + 3);
- if(TimeBlock->tm_mday < n) --nAge;
- }
- sprintf(pszAge, "%d", nAge);
- return;
- }
- }
- }
- }
- strcpy(pszAge, "?");
- }
- void ODStatStartArrowUse(void)
- {
- ++nArrowUseCount;
- }
- void ODStatEndArrowUse(void)
- {
- ASSERT(nArrowUseCount > 0);
- --nArrowUseCount;
- }
|