FUNC_TYPE(void) NAME_DEFINE(DllAbout) ( HWND hParent ) { char temp[300]; #if DIRECTX_VERSION == 8 sprintf(temp,"%s %s (%s)\nDirectX 8\nBased on Rice's 6.1.1 beta 10 source code",project_name, FILE_VERSION,BUILD_NUMBER) ; #else sprintf(temp,"%s %s (%s)\nDirectX 9\nBased on Rice's 6.1.1 beta 10 source code",project_name, FILE_VERSION,BUILD_NUMBER) ; #endif MsgInfo(temp); }
int resmgr_msg_again(resmgr_context_t *ctp, int rcvid) { if(MsgInfo(rcvid, &ctp->info) == -1) { return -1; } if((ctp->info.msglen = MsgRead(ctp->rcvid = rcvid, ctp->msg, ctp->msg_max_size, 0)) == -1) { return -1; } (void)MsgCurrent(rcvid); _resmgr_handler(ctp); return 0; }
/* * Actually do the reply to the client described by the blocked pointer, and * then afterward we have replied free the blocked strucuture. */ static void _iofunc_lock_unblock(iofunc_lock_list_t *list, struct _iofunc_lock_blocked *blocked) { struct _msg_info info; struct _io_lock_reply reply; struct iovec iov[2]; //Some initial sanity checking ... if (MsgInfo(blocked->rcvid, &info) == EOK && blocked->pflock && blocked->pflock->l_sysid == info.scoid) { SETIOV(&iov[0], &reply, sizeof(reply)); SETIOV(&iov[1], blocked->pflock, sizeof(*blocked->pflock)); (void)MsgReplyv(blocked->rcvid, EOK, iov, 2); } _iofunc_blocked_free(blocked); }
static int wait_unblock(resmgr_context_t *ctp, io_pulse_t *msg, void *ocb) { PROCESS *prp; struct _msg_info info; pid_t pid; pid = ctp->info.pid; if(ND_NODE_CMP(ctp->info.nd, ND_LOCAL_NODE) != 0) { /* unblock for wait over network */ pid = pathmgr_netmgr_pid(); if(pid == 0) { /* netmgr is gone */ return _RESMGR_NOREPLY; } } if((prp = proc_lock_pid(pid))) { // msg will be NULL if we're called from wait_close_ocb() if(msg && ((MsgInfo(ctp->rcvid, &info) == -1) || !(info.flags & _NTO_MI_UNBLOCK_REQ))) { proc_unlock(prp); return _RESMGR_NOREPLY; } if((prp->flags & (_NTO_PF_LOADING | _NTO_PF_TERMING)) == 0) { struct wait_entry *p, **pp; for(pp = &prp->wap; (p = *pp); pp = &p->next) { if(p->rcvid == ctp->rcvid) { *pp = p->next; if(prp->wap == NULL) { (void)_resmgr_unbind(&ctp->info); } MsgError(ctp->rcvid, EINTR); proc_object_free(&wait_souls, p); break; } } } proc_unlock(prp); } return _RESMGR_NOREPLY; }
QList<MsgInfo> History::getList(void) { QList<MsgInfo> list; lmcSettings settings; QString path = historyFile(); if(!QFile::exists(path)) return list; QFile file(path); if(!file.open(QIODevice::ReadOnly)) return list; QDataStream stream(&file); DBHeader header = readHeader(&stream); qint64 next = header.first; QString marker; qint64 offset; qint64 date; QString name; while(next != 0) { stream.device()->seek(next); MsgInfo info; stream >> marker; stream >> next; stream >> offset; stream >> date; stream >> name; list.append(MsgInfo(name, QDateTime::fromMSecsSinceEpoch(date), offset)); } return list; }
HRESULT CDXGraphicsContext::InitializeD3D() { // Prepare window for possible windowed/fullscreen change AdjustWindowForChange(); windowSetting.statusBarHeightToUse = 0; windowSetting.toolbarHeightToUse = 0; // Set up the presentation parameters //Clear out our presentation struct for use ZeroMemory( &m_d3dpp, sizeof(m_d3dpp) ); m_d3dpp.Windowed = m_bWindowed; m_d3dpp.BackBufferCount = 1; m_d3dpp.EnableAutoDepthStencil = TRUE; /*m_bUseDepthBuffer;*/ m_d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8; m_d3dpp.hDeviceWindow = m_hWnd; m_d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE; m_d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8; m_FSAAIsEnabled = false; if (options.DirectXAntiAliasingValue != 0 && m_maxFSAA > 0) { m_d3dpp.MultiSampleType = (D3DMULTISAMPLE_TYPE)(D3DMULTISAMPLE_NONE + min(m_maxFSAA, (int)options.DirectXAntiAliasingValue)); m_FSAAIsEnabled = true; //TRACE1("Start with FSAA=%d X", pDeviceInfo->MultiSampleType-D3DMULTISAMPLE_NONE); } if( currentRomOptions.N64FrameBufferEmuType != FRM_BUF_NONE && m_FSAAIsEnabled ) { m_FSAAIsEnabled = false; m_d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE; m_d3dpp.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER; TRACE0("FSAA is turned off in order to use BackBuffer emulation"); SetWindowText(g_GraphicsInfo.hStatusBar, "FSAA is turned off in order to use BackBuffer emulation"); } if( !m_FSAAIsEnabled ) m_d3dpp.SwapEffect = m_bWindowed ? D3DSWAPEFFECT_COPY : D3DSWAPEFFECT_FLIP; // Always use COPY for window mode else m_d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; // Anti-Aliasing mode windowSetting.uDisplayWidth = m_bWindowed ? windowSetting.uWindowDisplayWidth : windowSetting.uFullScreenDisplayWidth; windowSetting.uDisplayHeight = m_bWindowed ? windowSetting.uWindowDisplayHeight : windowSetting.uFullScreenDisplayHeight; m_d3dpp.FullScreen_RefreshRateInHz = m_bWindowed ? 0 : windowSetting.uFullScreenRefreshRate; if (m_d3dpp.FullScreen_RefreshRateInHz > m_displayMode.RefreshRate && !m_bWindowed) { m_d3dpp.FullScreen_RefreshRateInHz = m_displayMode.RefreshRate; windowSetting.uFullScreenRefreshRate = m_displayMode.RefreshRate; } m_d3dpp.BackBufferWidth = m_bWindowed ? 0 : windowSetting.uDisplayWidth; m_d3dpp.BackBufferHeight = m_bWindowed ? 0 : windowSetting.uDisplayHeight; // Create the device if(!SUCCEEDED(m_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, m_hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_PUREDEVICE, &m_d3dpp, &m_pd3dDevice ))) { if(!SUCCEEDED(m_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, m_hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &m_d3dpp, &m_pd3dDevice ))) { MsgInfo("Failed to initialize Direct3D"); return E_FAIL; } } if(m_pd3dDevice ) { g_pD3DDev = m_pd3dDevice; gD3DDevWrapper.SetD3DDev(m_pd3dDevice); // Store device Caps m_pd3dDevice->GetDeviceCaps( &m_d3dCaps ); if( m_bWindowed ) { SetWindowPos( m_hWnd, HWND_NOTOPMOST, m_rcWindowBounds.left, m_rcWindowBounds.top, ( m_rcWindowBounds.right - m_rcWindowBounds.left ), ( m_rcWindowBounds.bottom - m_rcWindowBounds.top ), SWP_SHOWWINDOW ); } // Store render target surface desc LPDIRECT3DSURFACE9 pBackBuffer; m_pd3dDevice->GetBackBuffer( 0, 0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer ); pBackBuffer->GetDesc( &m_d3dsdBackBuffer ); pBackBuffer->Release(); if ( CRender::IsAvailable() ) { CRender::GetRender()->InitDeviceObjects(); } m_bActive = true; return S_OK; } else { if( status.ToToggleFullScreen || !m_bWindowed ) SetWindowText(g_GraphicsInfo.hStatusBar,"Can not initialize DX9, check your Direct settings"); else MsgInfo("Can not initialize DX9, check your Direct settings"); } return E_FAIL; }
void ExportRegions() { int counter = 0; int dim_x = g_mapInfo.width / g_mapInfo.visTableWidth; int dim_y = g_mapInfo.height / g_mapInfo.visTableWidth; Msg("World size:\n [%dx%d] vis cells\n [%dx%d] regions\n", g_mapInfo.width, g_mapInfo.height, dim_x, dim_y); // print region map to console for(int i = 0; i < g_numRegionOffsets; i++, counter++) { // Debug information: Print the map to the console. Msg(g_regionOffsets[i] == REGION_EMPTY ? "." : "O"); if(counter == dim_x) { Msg("\n"); counter = 0; } } Msg("\n"); int numCellObjectsRead = 0; IFile* objFile = NULL; IFile* levModelFile = NULL; objFile = GetFileSystem()->Open(varargs("%s_CELLPOS_MAP.obj", g_levname.c_str()), "wb", SP_ROOT); levModelFile = GetFileSystem()->Open(varargs("%s_LEVELMODEL.obj", g_levname.c_str()), "wb", SP_ROOT); levModelFile->Print("mtllib %s_LEVELMODEL.mtl\r\n", g_levname.c_str()); int lobj_first_v = 0; int lobj_first_t = 0; // 2d region map // easy seeking for(int y = 0; y < dim_y; y++) { for(int x = 0; x < dim_x; x++) { int sPosIdx = y*dim_x + x; if(g_regionOffsets[sPosIdx] == REGION_EMPTY) continue; // determine region position int region_pos_x = x * 65536; int region_pos_z = y * 65536; // region at offset Spool* spool = (Spool*)((ubyte*)g_regionSpool + g_regionOffsets[sPosIdx]); Msg("---------\nSpool %d %d (offset: %d)\n", x, y, g_regionOffsets[sPosIdx]); Msg("offset: %d\n",spool->offset); Msg("connected areas offset: %d\n",spool->connected_areas); Msg("connected areas count: %d\n",spool->num_connected_areas); Msg("pvs block size: %d\n",spool->pvs_size); //Msg("padding: %d %d\n",spool->_padding,spool->_padding2); Msg("cell data size: %d\n",spool->cell_data_size); Msg("super regions: %d\n",spool->super_region); Msg("roadm size: %d\n",spool->roadm_size); Msg("roadh size: %d\n",spool->roadh_size); int cellsOffset = g_levInfo.spooldata_offset + 2048 * (spool->offset + spool->pvs_size + spool->cell_data_size); if(g_region_format.GetInt() == 2) // driver 2 demo { cellsOffset = g_levInfo.spooldata_offset + 2048 * (spool->offset + spool->pvs_size + spool->cell_data_size + spool->roadm_size ); } else if(g_region_format.GetInt() == 1) // driver 1 { ASSERT(!"diferrent packed cells used?\n"); } Msg("cell objects ofs: %d\n", cellsOffset); RegionModels_t* regModels = NULL; // if region data is available, load models and textures if(spool->super_region != SUPERREGION_NONE) { regModels = &g_regionModels[spool->super_region]; bool isNew = (regModels->modelRefs.numElem() == 0); LoadRegionData(g_levStream, regModels, &g_regionDataDescs[spool->super_region], &g_regionPages[spool->super_region]); if( g_export_models.GetBool() && isNew ) { // export region models for(int i = 0; i < regModels->modelRefs.numElem(); i++) { int mod_indxex = regModels->modelRefs[i].index; EqString modelFileName = varargs("%s/ZREG%d_MOD_%d", g_levname_moddir.c_str(), spool->super_region, mod_indxex); if(g_model_names[mod_indxex].GetLength()) modelFileName = varargs("%s/ZREG%d_%d_%s", g_levname_moddir.c_str(), spool->super_region, i, g_model_names[mod_indxex]); // export model ExportDMODELToOBJ(regModels->modelRefs[i].model, modelFileName.c_str(), regModels->modelRefs[i].index); } } } // seek to cells g_levStream->Seek(cellsOffset, VS_SEEK_SET); int cell_count = 0; objFile->Print("#--------\r\n# region %d %d (ofs=%d)\r\n", x, y, cellsOffset); objFile->Print("g cell_%d\r\n", sPosIdx); PACKED_CELL_OBJECT object; do { g_levStream->Read(&object, 1, sizeof(PACKED_CELL_OBJECT)); // bad hack, need to parse visibility data for it if( (0x4544 == object.pos_x && 0x2153 == object.addidx_pos_y) || (0x4809 == object.pos_x && 0x4809 == object.addidx_pos_y) || (0xA608 == object.pos_x && 0xA608 == object.addidx_pos_y) ||cell_count >= 8192) break; // unpack cell CELL_OBJECT cell; UnpackCellObject(object, cell); if(objFile) { objFile->Print("# m %d r %d\r\n", cell.modelindex, cell.rotation); objFile->Print("v %g %g %g\r\n", (region_pos_x+cell.x)*-0.00015f, cell.y*-0.00015f, (region_pos_z+cell.z)*0.00015f); } if(cell.modelindex >= g_levelModels.numElem()) { Msg("cell model index invalid: %d\n", cell.modelindex); cell_count++; continue; } MODEL* model = FindModelByIndex(cell.modelindex, regModels); if(!model) break; // transform objects and save Matrix4x4 transform = translate(Vector3D((region_pos_x+cell.x)*-0.00015f, cell.y*-0.00015f, (region_pos_z+cell.z)*0.00015f)); transform = transform * rotateY4(cell.rotation / 64.0f*PI_F*2.0f) * scale4(1.0f,1.0f,1.0f); WriteMODELToObjStream(levModelFile, model, cell.modelindex, false, transform, &lobj_first_v, &lobj_first_t, regModels); cell_count++; }while(true); MsgInfo("cell_count = %d\n", cell_count); if(objFile) { objFile->Print("# total region cells %d\r\n", cell_count); } numCellObjectsRead += cell_count; } } GetFileSystem()->Close(objFile); GetFileSystem()->Close(levModelFile); int numCellsObjectsFile = g_mapInfo.numAllObjects - g_mapInfo.numStraddlers; if(numCellObjectsRead != numCellsObjectsFile) MsgError("numAllObjects mismatch: in file: %d, read %d\n", numCellsObjectsFile, numCellObjectsRead); }
FUNC_TYPE(void) NAME_DEFINE(DllTest) ( HWND hParent ) { MsgInfo("We need to have a test function, don't we?"); }
EXPORT void CALL DllTest ( HWND hParent ) { MsgInfo((char*)"TODO: Test"); }
EXPORT void CALL DllAbout ( HWND hParent ) { char temp[300]; sprintf(temp,"%s %s \nOpenGL 1.1-1.4/ATI/Nvidia TNT/Geforce Extension\n", project_name, PLUGIN_VERSION); MsgInfo(temp); }
/* * Return -1 * This prp can never match the criteria * Return 0 * This prp does not currently match the criteria * Return WNOHANG * An error with wap, reply was done (i.e. a thread unblocked) * Return non-zero W????? * This prp matched and a reply was done (i.e. a thread unblocked) */ int procmgr_wait_check(PROCESS *prp, PROCESS *parent, struct wait_entry *wap, int match) { struct _msg_info info; /* * Check if this prp matched the requested group */ switch(wap->idtype) { case P_ALL: break; case P_PID: if(prp->pid != wap->id) { return -1; } break; case P_PGID: if(prp->pgrp != wap->id) { return -1; } break; default: MsgError(wap->rcvid, EINVAL); return WNOHANG; } if(match) { /* * Check for match, if parent is ignoring SIGCHLD, are we the last child? */ match &= wap->options; if(wap->idtype == P_ALL && (prp->sibling || parent->child != prp) && sigismember(&parent->sig_ignore, SIGCHLD)) { match &= ~WEXITED; } /* * Have we already responded with exit code? */ if(!(prp->flags & _NTO_PF_WAITINFO)) { match &= ~WEXITED; } } else { /* * Check if the requested prp currently matches any options */ if((wap->options & WTRAPPED) && (prp->flags & (_NTO_PF_DEBUG_STOPPED | _NTO_PF_PTRACED)) == (_NTO_PF_DEBUG_STOPPED | _NTO_PF_PTRACED)) { match = WTRAPPED; } else if((wap->options & WEXITED) && (prp->flags & _NTO_PF_WAITINFO)) { match = WEXITED; } else if((wap->options & WCONTINUED) && (prp->flags & _NTO_PF_CONTINUED)) { match = WCONTINUED; } else if((wap->options & WUNTRACED) && (prp->flags & _NTO_PF_STOPPED) && prp->siginfo.si_signo != 0) { match = WUNTRACED; } } /* * If no options matched, check if it could ever match options */ if(match == 0) { int options = wap->options; if(prp->flags & (_NTO_PF_ZOMBIE | _NTO_PF_TERMING)) { options &= ~(WUNTRACED|WTRAPPED|WCONTINUED); } if((prp->flags & (_NTO_PF_ZOMBIE | _NTO_PF_WAITINFO)) == _NTO_PF_ZOMBIE) { options &= ~WEXITED; } if((prp->flags & _NTO_PF_NOZOMBIE) || sigismember(&parent->sig_ignore, SIGCHLD)) { options &= ~WEXITED; } if(prp->flags & _NTO_PF_WAITDONE) { options &= ~WEXITED; } if(!(prp->flags & _NTO_PF_PTRACED)) { options &= ~WTRAPPED; } if((options & (WEXITED|WUNTRACED|WTRAPPED|WCONTINUED)) == 0) { return -1; } return 0; } /* * Unblock the waiting thread... */ if(MsgInfo(wap->rcvid, &info) != -1) { siginfo_t siginfo; // unbind and unblock if rcvid is still around if((!parent->wap) || ((parent->wap == wap) && (parent->wap->next == NULL))) { (void)_resmgr_unbind(&info); } siginfo = prp->siginfo; if(siginfo.si_signo != SIGCHLD) { if(prp->flags & _NTO_PF_COREDUMP) { siginfo.si_code = CLD_DUMPED; } else { siginfo.si_code = CLD_KILLED; } siginfo.si_status = siginfo.si_signo; siginfo.si_pid = prp->pid; siginfo.si_signo = SIGCHLD; } if(info.flags & _NTO_MI_ENDIAN_DIFF) { ENDIAN_SWAP32(&siginfo.si_signo); ENDIAN_SWAP32(&siginfo.si_code); ENDIAN_SWAP32(&siginfo.si_errno); ENDIAN_SWAP32(&siginfo.si_pid); ENDIAN_SWAP32(&siginfo.si_status); ENDIAN_SWAP32(&siginfo.si_utime); ENDIAN_SWAP32(&siginfo.si_stime); } MsgReply(wap->rcvid, 0, &siginfo, sizeof siginfo); } else { KerextSlogf( _SLOG_SETCODE( _SLOGC_PROC, 0 ), _SLOG_INFO, "proc_wait_check: MsgInfo() failed, errno=%d", errno); } /* * Clean up prp status if requested so it is not reported again */ if(wap->options & WNOWAIT) { return WNOWAIT; } switch(match) { case WEXITED: if(prp->flags & _NTO_PF_WAITINFO) { parent->kids_running_time += prp->running_time + prp->kids_running_time; parent->kids_system_time += prp->system_time + prp->kids_system_time; prp->flags &= ~_NTO_PF_WAITINFO; prp->flags |= _NTO_PF_WAITDONE; } if(prp->flags & _NTO_PF_ZOMBIE) { MsgSendPulse(PROCMGR_COID, prp->terming_priority, PROC_CODE_TERM, prp->pid); } else { match = WNOWAIT; } break; case WUNTRACED: // also WSTOPPED prp->siginfo.si_signo = 0; break; case WTRAPPED: break; case WCONTINUED: prp->flags &= ~_NTO_PF_CONTINUED; break; default: break; } return match; }
//接收socket连接线程 void * UdpServer::AcceptThread(void * pParam) { if(0 == pParam) { cout << "param is null." << endl; return 0; } UdpServer * pThis = (UdpServer*)pParam; int maxFd = 0; struct sockaddr_in cliAddr; while(true) { FD_ZERO(&pThis->mReadFd); FD_SET(pThis->mServerSocket, &pThis->mReadFd); maxFd = (pThis->mServerSocket > maxFd)? pThis->mServerSocket : maxFd; for(list<int>::iterator itor = pThis->mCliList.begin(); itor != pThis->mCliList.end(); itor++) { FD_SET(*itor, &pThis->mReadFd); maxFd = (*itor > maxFd)? *itor : maxFd; } int res = select(maxFd + 1, &pThis->mReadFd, 0, 0, NULL); if(-1 == res) { cout << "select failed." << endl; } if(-1 != pThis->mServerSocket && FD_ISSET(pThis->mServerSocket , &pThis->mReadFd)) { int sin_size = sizeof(struct sockaddr_in); int clientSoc = accept(pThis->mServerSocket, (struct sockaddr *)(&cliAddr), (socklen_t*)&sin_size); if(-1 == clientSoc) { cout << "accept error." << endl; continue; } if(DEBUG) cout << "Accept new client : " << clientSoc << endl; pThis->mCliList.push_front(clientSoc); string ip = inet_ntoa(cliAddr.sin_addr); char tmp[16] = {0}; sprintf(tmp, "%d", ntohs(cliAddr.sin_port)); string port = tmp; if(0 != pThis->mAcceptFunc) { pThis->mAcceptFunc(ip, port, clientSoc); } pThis->OnClientConnect(ip, port, clientSoc); } for(list<int>::iterator itor = pThis->mCliList.begin(); itor != pThis->mCliList.end(); itor++) { if(-1 != *itor && FD_ISSET(*itor , &pThis->mReadFd)) { char buf[MAX_MESSAGE_LEN] = {0}; int res = recv(*itor, buf, sizeof(buf), 0); if(0 < res) { if(DEBUG) cout << "Receive data : " << buf << endl; pthread_mutex_lock(&pThis->mMutex); pThis->mDataList.push_back(MsgInfo(*itor, buf)); pthread_mutex_unlock(&pThis->mMutex); } else if(0 == res) { cout << "client quit." << endl; pthread_mutex_lock(&pThis->mMutex); pThis->mCliList.remove(*itor); itor--; pThis->mDisconnectFunc(*itor); pThis->OnClientDisconnect(*itor); pthread_mutex_unlock(&pThis->mMutex); } else { cout << "receive failed." << endl; } } } } }