void WeaponsResource::SelectSlot(int iSlot, int fAdvance, int iDirection) { if(gHUD.m_Menu.m_fMenuDisplayed && (fAdvance == FALSE) && (iDirection == 1)) { // menu is overriding slot use commands gHUD.m_Menu.SelectMenuItem(iSlot); return; } if(iSlot > MAX_WEAPON_SLOTS) return; if(gHUD.m_fPlayerDead || gHUD.m_iHideHUDDisplay & (HIDEHUD_WEAPONS | HIDEHUD_ALL)) return; WEAPON *p = NULL; bool fastSwitch = CVAR_GET_FLOAT("hud_fastswitch") != 0; if((gpActiveSel == NULL) || (gpActiveSel == (WEAPON *)1) || (iSlot != gpActiveSel->iSlot)) { PlaySound("common/wpn_hudon.wav", 1); p = GetFirstPos(iSlot); if(p && fastSwitch) // check for fast weapon switch mode { // if fast weapon switch is on, then weapons can be selected in a single keypress // but only if there is only one item in the bucket WEAPON *p2 = GetNextActivePos(p->iSlot, p->iSlotPos); if(!p2) { // only one active item in bucket, so change directly to weapon //ServerCmd( p->szName ); g_weaponselect = iSlot; return; } } } else { PlaySound("common/wpn_moveselect.wav", 1); if(gpActiveSel) p = GetNextActivePos(gpActiveSel->iSlot, gpActiveSel->iSlotPos); if(!p) p = GetFirstPos(iSlot); } if(!p) // no selection found { // just display the weapon list, unless fastswitch is on just ignore it if(!fastSwitch) gpActiveSel = (WEAPON *)1; else gpActiveSel = NULL; } else gpActiveSel = p; }
BOOL CGuiControlBar::IsLegal(UINT uAlin) { m_First=GetFirstPos(); // if (IsFloating()) return FALSE; switch(uAlin) { case HTLEFT: if (IsHorz() && m_pos >0 && (m_pos != m_Last && m_pos != m_First)) return TRUE; if (IsVert() && m_pos <= m_Last && IsRight() ) return TRUE; return FALSE; break; case HTTOP: if (m_pos != m_First && IsVert()) return TRUE; if (IsHorz() && m_pos <= m_Last && IsBottom() ) return TRUE; return FALSE; break; case HTRIGHT: if (m_pos <= m_Last && IsVert() && IsLeft() ) return TRUE; if (IsHorz() && m_pos >0 && m_pos != m_Last) return TRUE; return FALSE; case HTBOTTOM: if ((m_pos != m_Last && m_pos != m_First) && IsHorz() && IsBottom()) return TRUE; if (m_pos <= m_Last && IsHorz() && IsTop()) return TRUE; //if (IsVert() && m_pos >0 ) return TRUE; return FALSE; break; } return FALSE; }
//ajusta las ventanas a redimencionarlas verticalmente //se decrementa las anteriores ventanas a la actual y se //incrementan las posteriores. void CGuiControlBar::AjustReDinSize(CPoint point) { int nFirstPos=GetFirstPos(); int nLastPos=GetLastPos(); int m_ThisPos=m_pDockBar->FindBar(this); ClientToScreen(&point); //si la diferencia es negativa esta barra crece la anterior a esta disminuye int nDif=0; BOOL bGrow=FALSE; if (IsVert()) { nDif=m_ptStartPos.y- point.y; if (nDif > 0) bGrow=TRUE; if (bGrow) m_sizeVert.cy+=abs(nDif)+4; else m_sizeVert.cy-=abs(nDif); if (nFirstPos == m_ThisPos) return; } else { nDif=m_ptStartPos.x- point.x; if (nDif < 0) bGrow=TRUE; if (bGrow) m_sizeHorz.cx+=abs(nDif); else m_sizeHorz.cx-=abs(nDif); if (nLastPos == m_ThisPos) return; } if (IsVert()) AjustVert(bGrow,nDif); else AjustHorz(bGrow,nDif); RecalWindowPos(); }
void Shot_ice::Damage(Game_Manager* gm_, Unit* unit_) { if(!unit_) return; int final_damge_ = unit_->SetDamage(gm_, GetFirstPos(), DT_FIRE ,damage, GetTeam()); unit_->SlowApply(slow_ratio,slow_turn, SK_ICE); if(unit) unit->GiveDamage(gm_, unit_, DT_FIRE, final_damge_); hit_unit.push_back(unit_); //후에 화염데미지도 넣는다. }
int CGuiControlBar::GetWidthMax() { m_pos=m_pDockBar->FindBar(this); m_Last=GetLastPos(); int nWidth=0; for (int nPos = GetFirstPos(); nPos <= m_Last; nPos++) { CGuiControlBar* pBar = GetGuiControlBar(nPos); if (pBar== NULL) continue; nWidth=max(nWidth,IsVert() ? pBar->m_sizeVert.cx:pBar->m_sizeHorz.cy); } return nWidth; }
//depende de la posicion se hace igual el tamanio del ancho o alto void CGuiControlBar::SetEqualWidth() { int nFirstPos=GetFirstPos(); for (int nPos = nFirstPos; nPos <= m_Last; nPos++) { CGuiControlBar* pBar = GetGuiControlBar(nPos); if (pBar== NULL) continue; if (IsHorz()) pBar->m_sizeHorz.cy=m_sizeHorz.cy;//rcDockBar.Height(); else pBar->m_sizeVert.cx=m_sizeVert.cx; } }
void CGuiToolBarWnd::SetRealSize() { CRect rcWinFrame; CRect rcThisBar; int nVisibles=0; int nThis = m_pDockBar->FindBar(this); int nFirst= GetFirstPos(); int nLast= GetLastPos(); UINT m_nDockBarID = m_pDockBar->GetDlgCtrlID(); int nMaxlen=GetHiWid(); int nLen=0; for (int i=nFirst;i <nLast; i++) { CGuiToolBarWnd* pBar; pBar = (CGuiToolBarWnd*) m_pDockBar->m_arrBars[i]; if (HIWORD(pBar) == 0) continue; if (!pBar->IsVisible()) continue; CRect rc; pBar->GetWindowRect(rc); if (IsVert()) nLen+=rc.Height() ; else nLen+= rc.Width() ; nVisibles++; } if ( nLen > nMaxlen) { int nDif=nLen-nMaxlen; } /* if (rcThisBar.Width() > nAfterThis) { if (nVisibles > 0) nAfterThis/=nVisibles; } */ }
bool CParticle::Update(float deltaTime) { m_Time +=deltaTime; Vect3f l_gravity = Vect3f(0.0f, 0.0f, 0.0f); if(m_bGravity) l_gravity = Vect3f(0.0f, -9.8f, 0.0f); if(m_Time < m_TimeToLive) { UpdateParams(deltaTime); //pos = (a*t^2)/2 + V0*t + pos0 //Vect3f l_oldPos = GetPos(); Vect3f l_oldPos = GetFirstPos(); SetPos(l_oldPos + m_Dir * m_Time + ((m_Acel + l_gravity) * (m_Time*m_Time))/2); //CBillboard::Update(camera, 0.0); CBillboard::Update(); return true; } return false; }
//esta rutina dispone de la posición en el Dockbar de la pila de ventanas void CGuiControlBar::RecalWindowPos() { int m_First=GetFirstPos(); int m_Last=GetLastPos(); int m_This=m_pDockBar->FindBar(this); CRect rcWin=GetDockRect(); int m_VertPos=0; for(int i=m_First; i<= m_Last; i++) { CGuiControlBar* pBar = GetGuiControlBar(i); if (pBar == NULL) continue; CRect rcBar; pBar->GetWindowRect(rcBar); rcBar.OffsetRect(-rcWin.TopLeft()); if (IsVert()) { if (i==m_First) rcBar.top=-2; else rcBar.top=m_VertPos; } else { if (i==m_First) rcBar.left=-2; else rcBar.left=m_VertPos; } pBar->MoveWindow(rcBar); m_VertPos+=IsVert()? rcBar.Height():rcBar.Width(); } m_pDockSite->RecalcLayout(); }
void CGuiControlBar::AjustHorz(BOOL bGrow,int nDif) { int nFirstPos=GetFirstPos(); int nLastPos=GetLastPos(); int m_ThisPos=m_pDockBar->FindBar(this); if(m_SideMove==HTRIGHT) { //Esta ventana crece las anteriores reducen su tamaño if (bGrow) { for (int i=m_ThisPos+1; i <= nLastPos; i++) { CGuiControlBar* pBar = GetGuiControlBar(i); if (pBar== NULL) return; if(IsHorz()) { if (pBar->m_sizeHorz.cx-abs(nDif) < pBar->m_sizeMinH.cx) { pBar->m_sizeHorz.cx=pBar->m_sizeMinH.cx; continue; } else { pBar->m_sizeHorz.cx-=abs(nDif); break; } } }//for }//bGrow else //este disminuye la anterior crece { if (m_ThisPos+1 <= m_Last) { CGuiControlBar* pBar = GetGuiControlBar(m_ThisPos+1); if (pBar== NULL) return; pBar->m_sizeHorz.cx+=abs(nDif); if(m_sizeHorz.cx > m_sizeMinH.cx) return; else pBar->m_sizeHorz.cx+=abs(nDif); } for (int i=m_ThisPos-1; i >0; i--) { CGuiControlBar* pBar = GetGuiControlBar(i); if (pBar== NULL) return; if(IsHorz()) { if (pBar->m_sizeHorz.cx-abs(nDif) < pBar->m_sizeMinH.cx) continue; else { pBar->m_sizeHorz.cx-=abs(nDif); return; } } }//for } } }
void CGuiControlBar::AjustVert(BOOL bGrow,int nDif) { int nFirstPos=GetFirstPos(); int nLastPos=GetLastPos(); int m_ThisPos=m_pDockBar->FindBar(this); if(m_SideMove==HTTOP) { //Esta ventana crece las anteriores reducen su tamaño if (bGrow) { for (int i=m_ThisPos-1; i > 0; i--) { CGuiControlBar* pBar = GetGuiControlBar(i); if (pBar== NULL) return; if(IsVert()) { if (pBar->m_sizeVert.cy-abs(nDif) < pBar->m_sizeMinV.cy) { pBar->m_sizeVert.cy=pBar->m_sizeMinV.cy; continue; } else { pBar->m_sizeVert.cy-=abs(nDif); break; } } }//for }//bGrow else //este disminuye la anterior crece { if (m_ThisPos-1 > 0) { CGuiControlBar* pBar = GetGuiControlBar(m_ThisPos-1); if (pBar== NULL) return; pBar->m_sizeVert.cy+=abs(nDif); if(m_sizeVert.cy > m_sizeMinV.cy) return; else pBar->m_sizeVert.cy-=m_sizeMinV.cy; } for (int i=m_ThisPos+1; i >= m_Last; i++) { CGuiControlBar* pBar = GetGuiControlBar(i); if (pBar== NULL) return; if(IsVert()) { if (pBar->m_sizeVert.cy-abs(nDif) < pBar->m_sizeMinV.cy) continue; else { pBar->m_sizeVert.cy-=abs(nDif); return; } } }//for } } }
//esta funcion calcula el tamaño horizontal de la ventana,no importa si esta //docking a izquierda o derecha o arriba o abajo.Debemos disponer de un espacio equitativo entre todas //ventanas que se encuentren docking ya sea en una fila o columna. CSize CGuiControlBar::CalcFixedLayout(BOOL bStretch, BOOL bHorz) { //la funcion original toma el ancho o alto dependiendo del sentido que nos //indica bHorz. ASSERT_VALID(this); if (IsFloating()) return m_sizeMinFloating; else { //si bStrerch es TRUE significa que esta ventana no se puede hacer //Docking if (bStretch) { if (bHorz) return CSize(32767, m_sizeHorz.cy); else return CSize(m_sizeVert.cx, 32767); } } int Len=GetHiWid(); int nWidth = GetWidthMax(); int nMinSpace=0;//minimo espacio requerido con lo tamaños normales int nMinimo=0; //minimo espacio de los tamaños minimos int nRealBars=0; int m_First=GetFirstPos(); for (int nPos = m_First; nPos <= m_Last; nPos++) { CGuiControlBar* pBar = GetGuiControlBar(nPos,TRUE); if (pBar== NULL) continue; if (!pBar->IsVisible()) continue; if (!pBar->IsKindOf(RUNTIME_CLASS(CGuiControlBar))) { CPoint pt(GetMessagePos()); m_pDockSite->FloatControlBar(pBar,pt); continue; } if(IsVert()) pBar->m_sizeVert.cx=nWidth; else pBar->m_sizeHorz.cy=nWidth; //todas se hacen con el mismo ancho nMinSpace+=IsVert() ? pBar->m_sizeVert.cy:pBar->m_sizeHorz.cx; //minimo espacio para alinear las barras nRealBars++; //cuantas barras realmente existen } //si el tamaño de las barras en la fila es mayor que //el espacio disponible, luego la solucion salomonica es //repartir el espacio entre todas. if (nRealBars == 1 ) { if (bHorz) return m_sizeHorz= CSize(Len,m_sizeHorz.cy); else return m_sizeVert=CSize(m_sizeVert.cx,Len); } int nDif=Len-nMinSpace; if (abs(nDif) !=0) { BOOL bGrow=FALSE; if (nDif > 0) bGrow=TRUE; nDif=abs(nDif); while(nDif > 0) { for (int nPos = m_First; nPos <= m_Last; nPos++) { CGuiControlBar* pBar = GetGuiControlBar(nPos); if (pBar== NULL) continue; if(IsVert()) { if(bGrow) pBar->m_sizeVert.cy+=1; else { if (pBar->m_sizeVert.cy-1 < pBar->m_sizeMinV.cy) continue; pBar->m_sizeVert.cy-=1; } } else { if(bGrow) pBar->m_sizeHorz.cx+=1; else { if (pBar->m_sizeHorz.cx-1 < pBar->m_sizeMinH.cx) continue; pBar->m_sizeHorz.cx-=1; } } nDif--; if(nDif==0) break; } } } //--reubicar las ventanas, sin esta rutina nada funciona RecalWindowPos(); if (IsHorz()) return m_sizeHorz; else return m_sizeVert; }
bool Shot_gun::Action(Game_Manager* gm_) { if(valid) { int coll_ = pre_collution(3); if(gm_) { for(list<Unit*>::iterator it = gm_->unit_list.begin();it != gm_->unit_list.end();it++) { if((*it)->isLive() && !(*it)->isNonTarget() && (*it)->GetTeam() != GetTeam()) { if(unit_collution((*it)->GetPos(), (*it)->GetSize()+((*it)->isPlayer()?0.0f:3.0f) )) { if (gm_->isPlayerCanHear(GetPos())) { PlaySE(se_bullet_flesh); } (*it)->SetKnockback(power, max_power, angle); if(slow_turn) (*it)->SlowApply(slow_ratio,slow_turn, SK_GUN); int final_damge_ = (*it)->SetDamage(gm_, GetFirstPos(), DT_BULLET, damage, GetTeam(), sniper, unit?unit->GetCritical():0); if(unit) unit->GiveDamage(gm_, (*it), DT_BULLET, final_damge_); valid = false; break; } } } } if(coll_) { SetPos(GetPos()+coord_def(cos(angle)*coll_, sin(angle)*coll_)); valid = false; delay++; } else Move(); distance -= const_speed; if(distance<0) valid = false; } if(valid && delay) { delay--; } else { delay_pos += GetSpeed(); if(!valid) { if(const_delay < delay++) return true; } } return false; }
int JV3_libLoad_DiskFile(HXCFLOPPYEMULATOR* floppycontext,FLOPPY * floppydisk,char * imgfile,void * parameters) { FILE * f; unsigned int filesize,cur_pos; unsigned int i,j,k,bitrate; unsigned short SectorSize, NumberofEntries; unsigned char gap3len,interleave,StartIdSector; unsigned short rpm; unsigned char trackformat; unsigned short sector_found; SECTORCONFIG* sectorconfig; CYLINDER* currentcylinder; JV3SectorHeader sh[JV3_HEADER_MAX]; JV3SectorsOffsets *pOffset, *SectorsOffsets; unsigned char write_protected; unsigned int inc; floppycontext->hxc_printf(MSG_DEBUG,"JV3_libLoad_DiskFile %s",imgfile); f=hxc_fopen(imgfile,"rb"); if(f==NULL) { floppycontext->hxc_printf(MSG_ERROR,"Cannot open %s !",imgfile); return HXCFE_ACCESSERROR; } fseek (f , 0 , SEEK_END); filesize=ftell(f); fseek (f , 0 , SEEK_SET); if(filesize!=0) { fread(sh, sizeof(JV3SectorHeader), JV3_HEADER_MAX, f); JV3_disk_geometry(sh, &floppydisk->floppyNumberOfSide, &floppydisk->floppySectorPerTrack, &floppydisk->floppyNumberOfTrack, &SectorSize, &StartIdSector, &NumberofEntries); fread(&write_protected, sizeof(write_protected), 1, f); // just to jump this infomation SectorsOffsets = JV3_offset(sh, floppydisk->floppyNumberOfSide, floppydisk->floppySectorPerTrack, floppydisk->floppyNumberOfTrack, NumberofEntries, f); bitrate=250000; rpm=300; interleave=1; gap3len=255; trackformat=IBMFORMAT_SD; floppydisk->floppyBitRate=bitrate; floppydisk->floppyiftype=GENERIC_SHUGART_DD_FLOPPYMODE; floppydisk->tracks=(CYLINDER**)malloc(sizeof(CYLINDER*)*floppydisk->floppyNumberOfTrack); floppycontext->hxc_printf(MSG_DEBUG,"rpm %d bitrate:%d track:%d side:%d sector:%d",rpm,bitrate,floppydisk->floppyNumberOfTrack,floppydisk->floppyNumberOfSide,floppydisk->floppySectorPerTrack); sectorconfig=(SECTORCONFIG*)malloc(sizeof(SECTORCONFIG)*floppydisk->floppySectorPerTrack); memset(sectorconfig,0,sizeof(SECTORCONFIG)*floppydisk->floppySectorPerTrack); for(j=0;j<floppydisk->floppyNumberOfTrack;j++) { floppydisk->tracks[j]=allocCylinderEntry(rpm,floppydisk->floppyNumberOfSide); currentcylinder=floppydisk->tracks[j]; for(i=0;i<floppydisk->floppyNumberOfSide;i++) { inc = 0; // used to build track data memset(sectorconfig,0,sizeof(SECTORCONFIG)*floppydisk->floppySectorPerTrack); sector_found=0; cur_pos = GetFirstPos(SectorsOffsets,NumberofEntries,j,i); for(k=0;k<floppydisk->floppySectorPerTrack;k++) { pOffset = GetSectorPosition(SectorsOffsets,NumberofEntries,cur_pos); if (pOffset == NULL) { inc += SectorSize; } else { sectorconfig[sector_found].sectorsize=pOffset->size; sectorconfig[sector_found].input_data=malloc(sectorconfig[sector_found].sectorsize); memset(sectorconfig[sector_found].input_data,0,sectorconfig[sector_found].sectorsize); fseek(f, pOffset->offset, SEEK_SET); fread(sectorconfig[sector_found].input_data,pOffset->size,1,f); inc += pOffset->size; if (pOffset->DAM != 0xFB) { sectorconfig[sector_found].use_alternate_datamark=1; sectorconfig[sector_found].alternate_datamark=pOffset->DAM; } if(pOffset->density) { sectorconfig[sector_found].trackencoding=IBMFORMAT_DD; if(!sector_found) trackformat=IBMFORMAT_DD; } else { sectorconfig[sector_found].trackencoding=IBMFORMAT_SD; if(!sector_found) trackformat=IBMFORMAT_SD; } if(pOffset->bad_sector) { sectorconfig[sector_found].use_alternate_data_crc = 0x01; sectorconfig[sector_found].data_crc = 0xAA55; } sectorconfig[sector_found].cylinder = pOffset->track_id; sectorconfig[sector_found].head = i; sectorconfig[sector_found].sector = pOffset->sector_id; sectorconfig[sector_found].bitrate = floppydisk->floppyBitRate; sectorconfig[sector_found].gap3 = gap3len; sector_found++; } cur_pos = GetNextPos(SectorsOffsets,NumberofEntries,j,i,cur_pos); } currentcylinder->sides[i]=tg_generateTrackEx(sector_found,sectorconfig,interleave,0,floppydisk->floppyBitRate,rpm,trackformat,0,2500|NO_SECTOR_UNDER_INDEX,-2500); for(k=0;k<floppydisk->floppySectorPerTrack;k++) { free(sectorconfig[k].input_data); } } } free(sectorconfig); free(SectorsOffsets); floppycontext->hxc_printf(MSG_INFO_1,"track file successfully loaded and encoded!"); hxc_fclose(f); hxcfe_sanityCheck(floppycontext,floppydisk); return HXCFE_NOERROR; } floppycontext->hxc_printf(MSG_ERROR,"file size=%d !?",filesize); hxc_fclose(f); return HXCFE_BADFILE; }