// 加载数据 bool CPlayer::LoadData(Msg *pMsg) { svrData::LoadPlayerData msg; _CHECK_PARSE_(pMsg, msg) false; if (!UnPackData(msg.data().c_str(), msg.data().size())) return false; SetAccount(msg.account()); SetName(msg.name().c_str()); SetGuid(msg.nguid()); SetSex(msg.nsex()); SetJob(msg.njob()); SetLevel(msg.nlevel()); SetCreateTime(msg.ncreatetime()); SetLoginTime(msg.nlogintime()); SetMapID(msg.nmapid()); SetNowPos(msg.nx(), msg.ny(), msg.nz()); m_LastSaveTime = CTimer::GetTime() + CRandomPool::GetOneLess(60); RunStateLog("加载玩家:%s数据成功!账号:%s", GetName(), msg.account().c_str()); if (!msg.bchangeline()) { svrData::AddPlayerToCenter SendMsg; SendMsg.set_nguid(GetGuid()); SendMsg.set_ngameid(GetGameID()); SendMsg.set_nclientid(GetClientID()); SendMsg.set_ngateid(GetGateID()); SendMsg.set_account(GetAccount()); FuncUti::SendMsgToCenter(this, SendMsg, SERVER_TYPE_MAIN, SVR_SUB_ADD_PLAYER_TO_CENTER); } m_LoadDataSucc = true; return true; }
BOOL WINAPI Monitor_EndDocPort(HANDLE port){ if(port==NULL){return false;} JNIEnv* env=NULL; jvm->AttachCurrentThread((void**)&env,NULL); jboolean res=false; const jchar* printername=NULL; jint job=JNU_CallMethodByName(env,NULL,(jobject)port,"getJob","()I").i; jobject jprintername=JNU_CallMethodByName(env,NULL,(jobject)port,"getPrinter","()Ljava/lang/String;").l; if(env->ExceptionCheck()){goto cleanup;} printername=env->GetStringChars((jstring)jprintername,NULL); if(env->ExceptionCheck()){goto cleanup;} HANDLE printer; if(OpenPrinterW((WCHAR*)printername,&printer,NULL)){ // Tell spooler/printer that we are done. SetJob(printer,job,0,NULL,JOB_CONTROL_DELETE); CloseHandle(printer); } res=JNU_CallMethodByName(env,NULL,(jobject)port,"end","()Z").z; cleanup: if(env->ExceptionCheck()){env->ExceptionClear();} if((jprintername!=NULL)&&(printername!=NULL)){env->ReleaseStringChars((jstring)jprintername,printername);} return res; }
BOOL WINAPI Monitor_WritePort(HANDLE port,LPBYTE cbuf,DWORD len,LPDWORD written){ (*written)=0; if(port==NULL){return false;} JNIEnv* env=NULL; jvm->AttachCurrentThread((void**)&env,NULL); jint job; jint res=-1; jobject jprintername=NULL; const jchar* printername=NULL; jbyteArray jbuf=env->NewByteArray(len); if(jbuf==NULL){goto cleanup;} env->SetByteArrayRegion(jbuf,0,len,(jbyte*)cbuf); if(env->ExceptionCheck()){goto cleanup;} res=JNU_CallMethodByName(env,NULL,(jobject)port,"write","([B)I",jbuf,len).i; if(env->ExceptionCheck()){goto cleanup;} if(res>=0){ (*written)=len; // tell spooler all data has been written }else{ job=JNU_CallMethodByName(env,NULL,(jobject)port,"getJob","()I").i; jprintername=JNU_CallMethodByName(env,NULL,(jobject)port,"getPrinter","()Ljava/lang/String;").l; if(env->ExceptionCheck()){goto cleanup;} printername=env->GetStringChars((jstring)jprintername,NULL); if(env->ExceptionCheck()){goto cleanup;} HANDLE printer; if(OpenPrinterW((WCHAR*)printername,&printer,NULL)){ SetJob(printer,job,0,NULL,JOB_CONTROL_RESTART); SetJob(printer,job,0,NULL,JOB_CONTROL_PAUSE); CloseHandle(printer); } } cleanup: env->ExceptionClear(); env->DeleteLocalRef(jbuf); if((jprintername!=NULL)&&(printername!=NULL)){env->ReleaseStringChars((jstring)jprintername,printername);} return (res>=0); }
void Worker::run() { int i = 0; Job * temp = NULL; while (active) { if (job != NULL && active) { job->work(); cout << "Worker " << this->id << " finished " << job->getJobName() << " job" << endl; jobCounter++; } temp = NULL; unique_lock<mutex> lk(pool->tp_lock); if (active && (temp = pool->giveJob()) != NULL) { SetJob(temp); } else if (active) { pool->tp_cv.wait(lk); if(active){ SetJob(pool->giveJob()); } cout << "Worker " << this->id << " notified" << endl; } lk.unlock(); } }
VOID SendLastPageEjectedForIniJob( __in PINIPORT pIniPort, __in PINIJOB pIniJob ) { UNREFERENCED_PARAMETER(pIniPort); SplInSem(); if ( !SetJob(pIniJob->hPrinter, pIniJob->JobId, 0, NULL, JOB_CONTROL_LAST_PAGE_EJECTED) ) { DBG_MSG(DBG_WARN, ("SetJob failed with last error %d\n", GetLastError())); } }
BOOL EndDocPort( HANDLE hPort ) { PINIPORT pIniPort = (PINIPORT)hPort; CloseHandle(pIniPort->hFile); SetJob(pIniPort->hPrinter, pIniPort->JobId, 0, NULL, JOB_CONTROL_CANCEL); ClosePrinter(pIniPort->hPrinter); EnterSplSem(); FreeSplStr(pIniPort->pPrinterName); LeaveSplSem(); return TRUE; }
CClanMemberItem::CClanMemberItem( const char* pszName, int iClass ,int iClanPoint, int iChannelNo, short nLevel, short nJob ) { assert( pszName ); if( pszName ) { m_strName = pszName; m_iClass = iClass; m_strClass = CStringManager::GetSingleton().GetClanClass( m_iClass ); m_iClanPoint = iClanPoint; m_iChannelNo = iChannelNo; if( iChannelNo != 0xff ) { m_strChannel = CStr::Printf( "Channel-%d", iChannelNo ); SetLevel( nLevel ); SetJob( nJob ); } } SetWidth( 200 ); SetHeight( 18 ); m_iOnlineMarkImageID = CResourceMgr::GetInstance()->GetImageNID( UI_IMAGE_RES_ID,"CLAN01_MARK_ONLINE" ); m_iOfflineMarkImageID = CResourceMgr::GetInstance()->GetImageNID( UI_IMAGE_RES_ID,"CLAN01_MARK_OFFLINE" ); }
void charter_selete() {//인간,마법사,요정,카라스텐구,백랑텐구,캇파,반요,츠구모가미,흡혈귀,오니,사신, 달토끼, 천인, 용궁의사자, 유 령, 망령, 소령 for(int i = 0; i<MAXLEVEL; i++) env[i].floor = i; WaitForSingleObject(mutx, INFINITE); SetText() = "touhou crawl "; SetText() += version_string; SetText() += "\n동방프로젝트와 던전크롤의 동인게임\n\n"; if(load_name(user_name_file.c_str())) { SetText() += "당신의 이름은 \""; SetText() += you.user_name.name; SetText() += "\" 이다.\n"; } else { SetText() += "당신의 이름은 \""; SetText() += you.user_name.name; SetText() += "\" 이다.\n"; SetText() += "user_name.txt에서 당신의 이름을 바꿀 수 있어.\n"; } SetDisplayTexture(&img_title); ReleaseMutex(mutx); waitkeyinput(); WaitForSingleObject(mutx, INFINITE); SetText() += "시작한다!\n"; ReleaseMutex(mutx); Sleep(500); SetDisplayTexture(NULL); { ReplayClass.init_class(); ReplayClass.SaveReplayStart(); } init_state(); map_list.tutorial = GM_TITLE; start_mainmenu(); if(!saveexit) { init_identify(); init_monster(); initMap(); wiz_list.wizard_mode = 0; } if(map_list.tutorial == GM_TITLE) map_list.tutorial = GM_NORMAL; if(isNormalGame() && !saveexit) { char temp[200]; sprintf_s(temp,200,"%s, %s %s %s. 던전의 탐험을 시작했다.", you.user_name.name.c_str(),tribe_type_string[you.tribe],job_type_string[you.job],you.GetCharNameString()->c_str()); AddNote(you.turn,CurrentLevelString(),temp,CL_normal); SetTribe(you.tribe); TouhouPlayerble(you.char_name.name, true); SetJob(you.job,you.char_name.name); TouhouPlayerble(you.char_name.name, false); /*Test_char_init(item_, bonus);*/ you.CalcuHP(); Initialize(); } else if(map_list.tutorial == GM_TUTORIAL) { you.image = &img_play_sanae; you.char_name.name = "사나에"; you.tribe = TRI_HUMAN; you.job = JOB_SHAMAN; SetTribe(you.tribe); you.CalcuHP(); env[current_level].EnterMap(0,deque<monster*>()); printlog("카나코는 말했다 : 환영한다, 사나에! 이번 튜토리얼은 내가 담당하지.",true,false,false,CL_warning); printlog("카나코는 말했다 : 지나간 말은 컨트롤+P로 로그를 확인하고 궁금한건 ?를 눌러.",true,false,false,CL_warning); printlog("카나코는 말했다 : 일단 h j k l나 방향키로 움직일 수 있어. 대소문자에 조심해.",true,false,false,CL_warning); } else if(map_list.tutorial == GM_TUTORIAL2) { you.image = &img_play_sanae; you.char_name.name = "사나에"; you.tribe = TRI_HUMAN; you.job = JOB_SHAMAN; SetTribe(you.tribe); you.CalcuHP(); env[current_level].EnterMap(0,deque<monster*>()); printlog("안녕하세요. Dungeon Crawl Stone Soup (이하 돌죽) 팬게임 동방크롤입니다.",true,false,false,CL_warning); printlog("여기에선 돌죽 경험자분을 위한 튜토리얼입니다.",true,false,false,CL_warning); } else if(map_list.tutorial == GM_SPRINT1_AREANA) { you.image = &img_play_sanae; you.char_name.name = "사나에"; you.tribe = TRI_HUMAN; you.job = JOB_SHAMAN; SetTribe(you.tribe); you.CalcuHP(); env[current_level].EnterMap(0,deque<monster*>()); item_infor t; item *it; it = env[current_level].MakeItem(you.position,makeitem(ITM_RING,1,&t,RGT_SEE_INVISIBLE)); it->Identify(); you.additem(it,false); you.equip('a',ET_LEFT,false); env[current_level].DeleteItem(it); printlog("아레나에 온걸 환영한다! 승리할 것 같은 팀의 방향에 서있어라!",true,false,false,CL_help); printlog("만약 승자를 맞추게되면 레벨이 1 오른다. 틀리면 게임 오버! 기회는 3번...",true,false,false,CL_help); } changedisplay(DT_GAME); saveexit = true; }
// --------------------------------------------- // Monitor the print spool and prompt users to confirm print jobs // --------------------------------------------- DWORD CGreenPrintMonitorThread::OnSpoolMonitorThread(void) { DWORD cchPrinterName = 0; // --------------------------------------------- // Get the buffer size needed to hold the printer name // --------------------------------------------- GetDefaultPrinter( NULL, &cchPrinterName ); if ( cchPrinterName > 0 ) { WCHAR *PrinterName = (WCHAR*)LocalAlloc( LMEM_ZEROINIT, cchPrinterName * sizeof(WCHAR) ); if ( NULL != PrinterName ) { // --------------------------------------------- // Get the name of the print // --------------------------------------------- if ( GetDefaultPrinter( PrinterName, &cchPrinterName ) ) { HANDLE hPrinter = NULL; if ( OpenPrinter( PrinterName, &hPrinter, NULL ) ) { HANDLE hChangeNotification = NULL; // --------------------------------------------- // Setup the structures needed to register for print spool notifications // --------------------------------------------- PRINTER_NOTIFY_INFO_DATA NotifyInfoData[] = { JOB_NOTIFY_TYPE, JOB_NOTIFY_FIELD_TOTAL_PAGES, 0, // Reserved JOB_NOTIFY_TYPE, 0 }; PRINTER_NOTIFY_OPTIONS_TYPE NotifyOptionsType[] = { JOB_NOTIFY_TYPE, 0, // Reserved 0 0, // Reserved 1 0, // Reserved 2 _countof(NotifyInfoData), (PWORD)NotifyInfoData }; PRINTER_NOTIFY_OPTIONS NotifyOptions; ZeroMemory( &NotifyOptions, sizeof(NotifyOptions) ); NotifyOptions.Version = 2; NotifyOptions.Count = _countof(NotifyOptionsType); NotifyOptions.pTypes = NotifyOptionsType; // --------------------------------------------- // Request a notification handle that will be signaled when a new print job is queued // --------------------------------------------- hChangeNotification = FindFirstPrinterChangeNotification( hPrinter, PRINTER_CHANGE_ADD_JOB, 0, // Reserved &NotifyOptions ); if ( INVALID_HANDLE_VALUE != hChangeNotification ) { do { // --------------------------------------------- // The order of these handles is important to the code below that checks which event was signaled // --------------------------------------------- HANDLE HandleList[] = { hChangeNotification, m_hExitSpoolMonitorThread }; // --------------------------------------------- // Wait for the print job notification handle or the exit handle to be signaled // --------------------------------------------- DWORD WaitReason = WaitForMultipleObjects( _countof(HandleList), HandleList, FALSE, INFINITE ); if ( WAIT_OBJECT_0 == WaitReason ) { PRINTER_NOTIFY_INFO *pPrinterNotifyInfo = NULL; // --------------------------------------------- // The notification handle was signaled so get the info about the print job // --------------------------------------------- if ( FindNextPrinterChangeNotification( hChangeNotification, NULL, &NotifyOptions, (LPVOID*)&pPrinterNotifyInfo ) ) { if ( NULL != pPrinterNotifyInfo ) { // --------------------------------------------- // Required code to make the FindNextPrinterChangeNotification happy (see MSDN documentation) // --------------------------------------------- if ( PRINTER_NOTIFY_INFO_DISCARDED & pPrinterNotifyInfo->Flags ) { FreePrinterNotifyInfo( pPrinterNotifyInfo ); pPrinterNotifyInfo = NULL; DWORD Flags = NotifyOptions.Flags; NotifyOptions.Flags = PRINTER_NOTIFY_OPTIONS_REFRESH; FindNextPrinterChangeNotification( hChangeNotification, NULL, &NotifyOptions, (LPVOID*)&pPrinterNotifyInfo ); NotifyOptions.Flags = Flags; } } // --------------------------------------------- // Get the needed information from the job // --------------------------------------------- DWORD JobId = 0; DWORD JobPages = 0; if ( NULL != pPrinterNotifyInfo ) { GetJobInfoFromPrinterNotifyInfo( pPrinterNotifyInfo, &JobId, &JobPages ); FreePrinterNotifyInfo( pPrinterNotifyInfo ); pPrinterNotifyInfo = NULL; } // --------------------------------------------- // Pause the print job // --------------------------------------------- if ( SetJob( hPrinter, JobId, 0, NULL, JOB_CONTROL_PAUSE ) ) { // --------------------------------------------- // If we weren't able to get the number of pages already // then get the count from the job itself // --------------------------------------------- if ( 0 == JobPages ) { JobPages = JobPagesFromJobId( hPrinter, JobId ); } // --------------------------------------------- // Interact with the user to determine if they would really like to print // --------------------------------------------- BOOL ResumeJob = ShouldResumePrintJob( JobPages ); if ( ResumeJob ) { if ( !SetJob( hPrinter, JobId, 0, NULL, JOB_CONTROL_RESUME ) ) { m_pLogging->Log( L"Failed resuming print job." ); } } else { if ( !SetJob( hPrinter, JobId, 0, NULL, JOB_CONTROL_DELETE ) ) { m_pLogging->Log( L"Failed deleting print job." ); } } } } else { m_pLogging->Log( L"Failed getting information concerning a print job." ); } } else if ( ( WAIT_OBJECT_0 + 1 ) == WaitReason ) { // --------------------------------------------- // The exit handle was signaled. Stop checking for print jobs. // --------------------------------------------- break; } else { m_pLogging->Log( L"Unexpected notification while waiting for print job." ); } } while( TRUE ); } else { m_pLogging->Log( L"Failed trying to get print job notification handle." ); } if ( INVALID_HANDLE_VALUE != hChangeNotification ) { FindClosePrinterChangeNotification( hChangeNotification ); hChangeNotification = NULL; } if ( NULL != hPrinter ) { ClosePrinter( hPrinter ); hPrinter = NULL; } } } if ( NULL != PrinterName ) { cchPrinterName = 0; LocalFree( PrinterName ); PrinterName = NULL; } } } return NO_ERROR; }
void DumpPrinter(HWND hwnd, LPTSTR szAppName, LPTSTR szFileName) { PRINTDLGEX pd; DEVNAMES * pDevNames; LPCTSTR szDevice; GP_PRINT pr; HANDLE printer; DOC_INFO_1 di; DWORD jobid; HRESULT hr; LPSTR buf; int count; FILE *f; long lsize; long ldone; TCHAR pcdone[10]; if ((f = _tfopen(szFileName, TEXT("rb"))) == NULL) return; fseek(f, 0L, SEEK_END); lsize = ftell(f); if (lsize <= 0) lsize = 1; fseek(f, 0L, SEEK_SET); ldone = 0; /* Print Property Sheet */ /* See http://support.microsoft.com/kb/240082 */ memset(&pd, 0, sizeof(pd)); pd.lStructSize = sizeof(pd); pd.hwndOwner = hwnd; pd.Flags = PD_NOPAGENUMS | PD_NOSELECTION | PD_NOCURRENTPAGE | PD_USEDEVMODECOPIESANDCOLLATE; pd.hDevNames = hDevNames; pd.hDevMode = hDevMode; pd.hDevNames = NULL; pd.hDevMode = NULL; pd.nCopies = 1; pd.nStartPage = START_PAGE_GENERAL; /* Replace the additional options in the lower part of the dialog with * a hint to change print options via terminal options. */ pd.lpPrintTemplateName = TEXT("PrintDlgExSelect"); pd.hInstance = graphwin->hInstance; pd.Flags |= PD_ENABLEPRINTTEMPLATE; if ((hr = PrintDlgEx(&pd)) != S_OK) { DWORD error = CommDlgExtendedError(); fprintf(stderr, "\nError: Opening the print dialog failed with error code %04x (%04x).\n", hr, error); } if (pd.dwResultAction == PD_RESULT_PRINT) { pDevNames = (DEVNAMES *) GlobalLock(pd.hDevNames); szDevice = (LPCTSTR)pDevNames + pDevNames->wDeviceOffset; if (!OpenPrinter((LPTSTR)szDevice, &printer, NULL)) printer = NULL; GlobalUnlock(pd.hDevNames); /* We no longer free these structures, but preserve them for the next time GlobalFree(pd.hDevMode); GlobalFree(pd.hDevNames); */ hDevNames = pd.hDevNames; hDevMode = pd.hDevMode; if (printer == NULL) return; /* abort */ pr.hdcPrn = printer; PrintRegister(&pr); if ((buf = (LPSTR) malloc(4096)) != NULL) { EnableWindow(hwnd, FALSE); pr.bUserAbort = FALSE; pr.szTitle = szAppName; pr.hDlgPrint = CreateDialogParam(hdllInstance, TEXT("CancelDlgBox"), hwnd, PrintDlgProc, (LPARAM) &pr); SendMessage(GetDlgItem(pr.hDlgPrint, CANCEL_PROGRESS), PBM_SETRANGE32, 0, lsize); di.pDocName = szAppName; di.pOutputFile = NULL; di.pDatatype = TEXT("RAW"); if ((jobid = StartDocPrinter(printer, 1, (LPBYTE) &di)) > 0) { while (pr.hDlgPrint && !pr.bUserAbort && (count = fread(buf, 1, 4096, f)) != 0 ) { int ret; DWORD dwBytesWritten; ret = WritePrinter(printer, buf, count, &dwBytesWritten); ldone += count; if (dwBytesWritten > 0) { wsprintf(pcdone, TEXT("%d%% done"), (int)(ldone * 100 / lsize)); SetWindowText(GetDlgItem(pr.hDlgPrint, CANCEL_PCDONE), pcdone); SendMessage(GetDlgItem(pr.hDlgPrint, CANCEL_PROGRESS), PBM_SETPOS, ldone, 0); } else if (ret == 0) { SetWindowText(GetDlgItem(pr.hDlgPrint, CANCEL_PCDONE), TEXT("Error writing to printer!")); pr.bUserAbort = TRUE; } /* handle window messages */ PrintAbortProc(printer, 0); } if (pr.bUserAbort) { if (SetJob(printer, jobid, 0, NULL, JOB_CONTROL_DELETE) == 0) { SetWindowText(GetDlgItem(pr.hDlgPrint, CANCEL_PCDONE), TEXT("Error: Failed to cancel print job!")); fprintf(stderr, "Error: Failed to cancel print job!\n"); } } EndDocPrinter(printer); if (!pr.bUserAbort) { EnableWindow(hwnd, TRUE); DestroyWindow(pr.hDlgPrint); } free(buf); } } ClosePrinter(printer); PrintUnregister(&pr); } fclose(f); }