#include <time.h>
#include <iostream>
#include <Windows.h>

using namespace std;

int main()
{
	cout << "http://fehead.tistory.com/" << endl;

	for( ;; )
	{
		time_t now = time( 0 );		
		
		// 자정(오늘의 0시 시각을 구함)
		struct tm todayStartTm;
		localtime_s( &todayStartTm, &now );
		todayStartTm.tm_sec = 0;
		todayStartTm.tm_min = 0;
		todayStartTm.tm_hour = 0;

		// 자정부터 현재까지 지난 초를 구함
		time_t  todayTotalSec = now - mktime( &todayStartTm );		

		// 에린의 현재 누적된 분(Min)을 구함.
		// (에린시간은 1.5초당 1분이 지나기 때문에 1.5로 나누었음.)
		time_t erinTotalMin = static_cast<time_t>( todayTotalSec / 1.5 );
		
		// 에린의 하루 시간을 구함.
		//  누적된 시간에서 오늘로부터 지난 시간을 구함(24 * 60 - 하루)
		time_t erinTodayMin = erinTotalMin % (60*24);

		time_t erinHour = erinTodayMin / 60;			// 에린시간 시
		time_t erinMin = erinTodayMin % 60;			// 에린시간 분

		cout << erinHour << " : " << erinMin << endl;	// 시간 출력

		Sleep( 1000 );
	}

	return 0;
}

호로양 Gif에서 에서 글자를 뺀것



용량 최적화 한것


간단하게 디렉토리를 압축할수 있게하는 라이브러리이다.

http://joyholic.kr/trackback/32


위 사이트를 참고하여
Zlib( http://www.winimage.com/zLibDll/index.html )
MiniZip( http://www.winimage.com/zLibDll/minizip.html )
zipunzip 라이브러리( http://www.codeproject.com/KB/cpp/zipunzip.aspx )

사이트에 가서 해당 소스를 가져와 소스를 합치고 해서 visual c++ 2008에서 컴파일 했다.

파일은 두개인데
한개는 ZipUnzip 라이브러리 파일이고
한개는 ZipUnzip라이브러리를 사용한 샘플파일( 위사이트에서 참고한 파일 )이다.

사용법은 아래와 같다.


// DirectoryZip  --- c:\tmp 디렉토리를 c:\tmp.zip 으로 압축
        CZipper zip;

        if (zip.OpenZip("c:\\tmp.zip", false))
                zip.AddFolderToZip("c:\\tmp", false);

// FileZip --- c:\tmp\test.txt 파일을 c:\tmp.zip 으로 압축
        CZipper zip;

        if (zip.OpenZip("c:\\tmp.zip", false))
                zip.AddFileToZip("c:\\tmp\\text.txt", false);

// Unzip --- c:\tmp.zip 을 c:\tmp에 압축해제
        CUnzipper uz;
        bool br = uz.OpenZip("c:\\tmp.zip");
        if(br)
                br = uz.UnzipTo("c:\\tmp");
아래 샘플 코드의 실행 방법은 인자를 붙여 실행합니다.
 ZipUnzip.exe c C:\tmp  ==> c:\tmp 디렉토리를 압축하여 c:\tmp.zip 파일을 만든다.
 ZipUnzip.exe d C:\tmp ==> c:\tmp.zip 파일을 압축해제하여 c:\tmp에 압축을 푼다.

압축을 해제할때 필요.

예제 소스
http://www.opensource.apple.com/source/gcc3/gcc3-1161/fastjar/dostime.c

/*
  dostime.c - routines for converting UNIX time to MS-DOS time.  

  Borrowed from Info-zip's unzip

  Copyright (C) 1999 Bryan Burns

  This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU General Public License
  as published by the Free Software Foundation; either version 2
  of the License, or (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

/* $Id: dostime.c,v 1.3 2001/09/17 20:35:55 zlaski Exp $

   $Log: dostime.c,v $
   Revision 1.3  2001/09/17 20:35:55  zlaski
   Resolve conflicts due to 2001-09-12 FSF import.

   Revision 1.2  2000/12/14 18:45:35  ghazi
   Warning fixes:

   	* compress.c: Include stdlib.h and compress.h.
   	(rcsid): Delete.
   	(report_str_error): Make static.
   	(ez_inflate_str): Delete unused variable.  Add parens in if-stmt.
   	(hrd_inflate_str): Likewise.

   	* compress.h (init_compression, end_compression, init_inflation,
   	end_inflation): Prototype void arguments.

   	* dostime.c (rcsid): Delete.

   	* jargrep.c: Include ctype.h, stdlib.h, zlib.h and compress.h.
   	Make functions static.  Cast ctype function argument to `unsigned
   	char'.  Add parens in if-stmts.  Constify.
   	(Usage): Change into a macro.
   	(jargrep): Remove unused parameter.

   	* jartool.c: Constify.  Add parens in if-stmts.  Align
   	signed/unsigned char pointers in functions calls using casts.
   	(rcsid): Delete.
   	(list_jar): Fix printf format specifier.
   	(usage): Chop long string into bits.  Reformat.

   	* pushback.c (rcsid): Delete.

   Revision 1.1  2000/12/09 03:08:23  apbianco
   2000-12-08  Alexandre Petit-Bianco  < apbianco@cygnus.com >

           * fastjar: Imported.

   Revision 1.1.1.1  1999/12/06 03:09:12  toast
   initial checkin..



   Revision 1.6  1999/05/10 08:32:26  burnsbr
   added dos2unixtime

   Revision 1.5  1999/04/27 10:03:50  burnsbr
   configure support

   Revision 1.4  1999/04/26 21:55:19  burnsbr
   switched from sys/time.h to time.h for better portability

   Revision 1.3  1999/04/20 08:54:30  burnsbr
   added GPL comment

   Revision 1.2  1999/04/20 05:10:53  burnsbr
   added RCS tags


*/
#include "config.h"

#ifdef TM_IN_SYS_TIME
#include < sys/time.h >
#else
#include < time.h >
#endif

#include "dostime.h"

/*

 Copyright (C) 1990-1997 Mark Adler, Richard B. Wales, Jean-loup Gailly,
 Kai Uwe Rommel, Onno van der Linden and Igor Mandrichenko.
 Permission is granted to any individual or institution to use, copy, or
 redistribute this software so long as all of the original files are included,
 that it is not sold for profit, and that this copyright notice is retained.

*/


time_t dos2unixtime(dostime)
     unsigned long dostime;            /* DOS time to convert */
     /* Return the Unix time_t value (GMT/UTC time) for the DOS format (local)
      * time dostime, where dostime is a four byte value (date in most
      * significant word, time in least significant word), see dostime() 
      * function.
      */
{
  struct tm *t;         /* argument for mktime() */
  time_t clock = time(NULL);

  t = localtime(&clock);
  t->tm_isdst = -1;     /* let mktime() determine if DST is in effect */
  /* Convert DOS time to UNIX time_t format */
  t->tm_sec  = (((int)dostime) <<  1) & 0x3e;
  t->tm_min  = (((int)dostime) >>  5) & 0x3f;
  t->tm_hour = (((int)dostime) >> 11) & 0x1f;
  t->tm_mday = (int)(dostime >> 16) & 0x1f;
  t->tm_mon  = ((int)(dostime >> 21) & 0x0f) - 1;
  t->tm_year = ((int)(dostime >> 25) & 0x7f) + 80;

  return mktime(t);
}

unsigned long dostime(y, n, d, h, m, s)
int y;                  /* year */
int n;                  /* month */
int d;                  /* day */
int h;                  /* hour */
int m;                  /* minute */
int s;                  /* second */
/* Convert the date y/n/d and time h:m:s to a four byte DOS date and
   time (date in high two bytes, time in low two bytes allowing magnitude
   comparison). */
{
  return y < 1980 ? dostime(1980, 1, 1, 0, 0, 0) :
    (((unsigned long)y - 1980) << 25) | ((unsigned long)n << 21) | 
    ((unsigned long)d << 16) | ((unsigned long)h << 11) | 
    ((unsigned long)m << 5) | ((unsigned long)s >> 1);
}


unsigned long unix2dostime(t)
time_t *t;             /* unix time to convert */
/* Return the Unix time t in DOS format, rounded up to the next two
   second boundary. */
{
  time_t t_even;
  struct tm *s;         /* result of localtime() */

  t_even = (*t + 1) & (~1);     /* Round up to even seconds. */
  s = localtime(&t_even);       /* Use local time since MSDOS does. */
  return dostime(s->tm_year + 1900, s->tm_mon + 1, s->tm_mday,
                 s->tm_hour, s->tm_min, s->tm_sec);
}
utime
       #include < sys/types.h >
       #include < utime.h >

       int utime(const char *filename, const struct utimbuf *times);

예제 참고
http://www.joinc.co.kr/modules/moniwiki/wiki.php/man/2/utime

#include < sys/types.h >
#include < utime.h >
#include < sys/time.h >
#include < stdio.h >
#include < string.h >

int main()
{
    struct utimbuf ubuf;
    ubuf.actime = time((time_t *)0);
    ubuf.modtime = time((time_t *)0);

    // 접근,수정 시간을 현재 시간으로 변경한다.
    utime("sizeof.c", NULL);

    // NULL 대신 actime,modtime 을 세팅해서 
    // 직접 값을 지정해줄수도 있다. 
    utime("sizeof.c", &ubuf);
    return 0;
}
해당 범위를 벗어나면 락을 해제하는 패턴.

예제 1 ) Scoped Locking 패턴을 사용하지 않은 예제
 변수 m 은 뮤텍스.

virtual int handle_data()
{
    while( log_record() != -1 )
    {
        if( m.acquire() == -1 ) return 0;
        ++request_count;    // 요청개수 증가
        m.release();        // 잠금해제
    }

    m.acquire();
    int cnt = request_count;
    m.release();
    cout << "request_count" = " << cnt << endl;
}

예제 2 ) Scoped Locking 패턴을 사용한 예제
 변수 m 은 뮤텍스.

virtual int handle_data()
{
    while( log_record() != -1 )
    {
        // 생성자에서 잠금 획득
        ACE_GUARD_RETURN ( ACE_Thread_Mutex, guard, m , -1 );
        ++request_count;    // 요청개수 증가
        // 소멸자에서 잠금 해제.
    }

    {
        // 생성자에서 잠금 획득
        ACE_GUARD_RETURN ( ACE_Thread_Mutex, guard, m , -1 );
        int cnt = request_count;
        // 소멸자에서 잠금 해제.
    }

    cout << "request_count" = " << cnt << endl;
}
아무것도 하지 않는 객체를 만드는것.

예제)

class ACE_Null_Mutex
{
public:
    ACE_Null_Mutex( const char * = 0, ACE_mutexattr_t * = 0 ) {}
    int acquire() { return 0; }
    int release() { return 0; }
    // ....
};
첨부 파일을 참고 하세요.



/// @brief    파일이나 디렉토리가 있는지 확인.
bool IsExist(const string & file);

// 파일 경로와 관계된 모든 부모 디렉토리를 만든다.
bool DigPath( const string & fullPath );

// 디렉토리인지 알아냄.
bool IsDirectory( const string & path );

// 조건 1. src_file 및 dst_file은 풀 파일명이여야 함.
bool FileCopy(const string & src_file, const string & dst_file);

bool FileMove(const string & src_file, const string & dst_file);

bool CopyDir(const string & src_dir, const string & dst_dir, const bool src_remove);

bool MoveDir( const string & src_dir, const string & dst_dir );

// . .. 디렉토리인지 검사.
bool IsDotDirectory( const string & x );

/// @brief    파일인지 검사함.
bool IsFile(const string & src);


Reactor::run_reactor_event_loop 종료후에 다시 Reactor를 썼더니 문제가 일어났다.

문제는 Reactor::notify(handler,mask) 호출이 되지 않는 문제가 발생하여

ACE_Reactor_Notification_Strategy 클래스가 작동을하지 않았다.

그래서 Reactor::reset() 를 호출해봤지만 되지 않았다.

결론은 ACE_Reactor::instance()->reset_reactor_event_loop();

이걸로 해결되었다. ㅎㅎ
게임을 제대로 재밌게 하는 방법을
마비노기라는 게임을 통해서 어느정도 파악한것 같다

최근 심리학책을 3번째 읽었다.

그리고 마비노기 게임속에 심리학적인 면이 있다고 생각되었다.

게임은 일단 재미있어야 한다.
하지만 오랫동안 지속적으로 재밌는것은 힘들다.

그 중간 중간에 심리학적으로 재밌게 만들어 아니 사실은
게임 사용자들이 게임에서 빠져 나갈수 없게 만드는 요소를 집어넣어야 한다.

그것을 마비노기 게임에 있는것 같다.

바로 노가다 같은 스킬 얻기이다.
하지만 그 노가다 같은 스킬을 얻으면 게임은 재밌어지고 그전보다 하기도 수월해 진다.

이는 심리학적으로도 확인이 된다.
어느 학교 기숙사에서는 기숙사에 들어가기 위한 학생들만으로 만들어진 절차가 있다고 한다.
예를 들면 한 겨울에 속옷만 입힌채로 산 중간에 버려져서 기숙사로 돌아오기
일정한 크기로 잘려진 생 날간을 먹기 그리고 선배들에게 둘려쌓여 폭행을 당하기

일반적으로 생각하면 폭행집단이 아닌가로 생각되지만
실상은 아주 훌륭한 학교의 기숙사라고 한다.
그들은 학교생활에 적극적이며 학교 생활에 만족하며 산다고 한다.

이는 어떤 일은 하는데 있어서 고통을 겪고 나서 얻은 결과물은
자기에게 더욱 크게 느껴지고되고 만족감도 높다라고 느껴지는것이라고 한다.

이게 게임속에 있다.
마비노기 중에 "윈드밀", "제련" 스킬이 있는데 이것들이 이에 해당되지 않나 싶다.
"윈드밀" 스킬을 마스터(1랭)하는데 엄청난 노가다를 해야한다.

아마 내가 순수 윈드밀 스킬로 마지막타로 죽인 몬스터 수가
아마 3만 마리는 된거같다(정확하지 않으니 참고만^^)
이걸 마스터 할려고 몇달을 고생했다(주말족이라 토, 일요일만 했습니다^^)

하지만 마스터 하고 나서는 신천지가 되었다.
게임하는데 하기전과 엄청나게 수월해졌다.
특히 이스킬은 2랭크와 1랭크와 차이가 어마어마 한데

그게 또한 심리학적으로도 고차원적인 생각으로 만들어진것 같은 기분이든다.
이 게임의 이 스킬을 기획한 기획자를 만나서 이야기를 듣고 싶다^^

게임과 심리학.. 이건 엄청난것 같다^^

리니지같은 게임에도 심리학이 있는것 같다.
리니지는 레벨과 레벨사이의 차이가 엄청나다고 들었다.

불과 레벨 1차이로 1:5~10 도 능히 처리가 가능하다고 들었다.
1레벨을 획득하면 자신에게 엄청난 해택이 주어진다.

그리고 웃기는 것은 아니 놀라운 사실은
이것을 게임이 아닌 실 생활에도 나의 생활에도 적용할수 있다는것이 놀랍다.

자기가 하는것을 좀더 재미있게 하는데에 쓸수 있다.
바로 자기가 하는일 중 정말로 힘들게 노력해서 어떤것을 얻을수 있다면
도전해 보는것도 그중 하나가 아닐까?


+ Recent posts