Esempio n. 1
0
int MoveCamera(int Length)
{
  Level *level;
  level = GetCurrentLevel(CurrentLevel);
  if(Abs_Camera.x + Camera.w >= LevelSprite->w * level->length)return 0;//we are done already.
  Abs_Camera.x += Length;
  Camera.x += Length;
  if(Camera.x > Camera.w)
  {
    SDL_BlitSurface(buffer,&Camera,buffer,NULL);
    UpdateLevel(level);
    Camera.x = 0;
  }
  return 1;
}
Esempio n. 2
0
void CDialingDirDlg::RecurseDialingDir(CStdioFile *fDialingDir, int nLevel, HTREEITEM hParent)
{
    SDialingDir sDialingDir;
    HTREEITEM hTreeItem = TVI_ROOT;
    char szDescription[128];
    char *pTok;
    int nCurrentLevel;
    do
    {
        memset(&sDialingDir, 0, sizeof(SDialingDir));
        nCurrentLevel = GetCurrentLevel();
        if (nCurrentLevel > nLevel)
        {
            RecurseDialingDir(fDialingDir, nCurrentLevel, hTreeItem);
            if (strlen(m_szInput) == 0)
            {
                return;
            }
            nCurrentLevel = GetCurrentLevel();
        }
        if (nCurrentLevel < nLevel)
        {
            return;
        }
        strcpy(sDialingDir.szDescription, m_szInput + nCurrentLevel);
        pTok = strtok(m_szInput, " ");
        if (_strnicmp(pTok + nCurrentLevel, DCOM_TELNET_ID, sizeof(DCOM_TELNET_ID)) == 0)
        {
            sDialingDir.nType = DCOM_DD_TELNET;
        }
        else if (_strnicmp(pTok + nCurrentLevel, DCOM_SSH_ID, sizeof(DCOM_SSH_ID)) == 0)
        {
            sDialingDir.nType = DCOM_DD_SSH;
        }
        pTok = strtok(NULL, " ");
        if (pTok)
        {
            strcpy(sDialingDir.szAddress, pTok);
        }
        pTok = strtok(NULL, " ");
        if (pTok)
        {
            sDialingDir.nPort = atoi(pTok);
        }
        pTok = strtok(NULL, "\n");
        if (pTok)
        {
            strcpy(sDialingDir.szDescription, pTok);
        }
        Trim(sDialingDir.szDescription);
        m_sDialingDir.push_back(sDialingDir);
        if (sDialingDir.nPort > 0)
        {
            sprintf(szDescription, "%s - %s %i", sDialingDir.szDescription, sDialingDir.szAddress, sDialingDir.nPort);
        }
        else
        {
            sprintf(szDescription, "%s", sDialingDir.szDescription);
        }
        hTreeItem = m_dialingDirTree.InsertItem(szDescription, hParent);
        m_dialingDirTree.SetItemData(hTreeItem, m_sDialingDir.size() - 1);
        memset(m_szInput, 0, sizeof(m_szInput));
    } while (fDialingDir->ReadString(m_szInput, sizeof(m_szInput)));
}
void InfosGatherVisitor::VisitIf(If * ifNode) {
   VisitBloc(ifNode->GetBloc(),GetCurrentLevel());
}
void InfosGatherVisitor::VisitMain(Main* mainNode) {
   VisitBloc(mainNode->GetBloc(), GetCurrentLevel());
}
void InfosGatherVisitor::VisitWhile(While* whileNode) {
   VisitBloc(whileNode->GetBloc(), GetCurrentLevel());
}
void InfosGatherVisitor::VisitFunctionDecaration(FunctionDeclaration * functionDecl) {
   VisitBloc(functionDecl->GetBloc(), GetCurrentLevel());
}
void InfosGatherVisitor::VisitFor(For * forNode) {
   VisitBloc(forNode->GetBloc(), GetCurrentLevel());
}
void InfosGatherVisitor::VisitElse(Else * elseNode) {
   VisitBloc(elseNode->GetBloc(), GetCurrentLevel());
}
Esempio n. 9
0
void GameController::PlayerReadyMoveProjection(hdTimeInterval interval)
{
    // While the projection is not at the starting position (0.0, upper.x = level.upper.x)
    // move a fraction of the difference between the aabb and the destination.
    float dx, dy;
    dx = dy = 0.0f;

    Block* keyBlock = NULL;

    // find block with tag of 1001 - camera focuses on this block when player is ready...
    for (int i = 0; i < GetCurrentLevel()->GetBlockCount(); i++)
    {
        if (GetCurrentLevel()->GetBlocks()[i]->GetTag() == 1001)
        {
            keyBlock = (Block*)GetCurrentLevel()->GetBlocks()[i];
            SetSelectedTotemBlock(keyBlock);
            break;
        }
    }

    if (keyBlock == NULL)
    {
        /*
         * HACK HACK HACK
         *
         * Focus on the center if there is no key block.
         */
        float worldCenterX = (m_worldAABB.upper.x + m_worldAABB.lower.x) / 2.0f;
        float projCenterX = m_projection->GetAABB().lower.x + ((m_projection->GetAABB().upper.x - m_projection->GetAABB().lower.x) / 2.0f);

        if (m_projection->GetAABB().upper.y <= m_worldAABB.upper.y)
        {
            // move clamped to diff between y
            dy = 0.2f;
        }

        if (projCenterX <= worldCenterX)
        {
            dx = hdMin(0.2f, (projCenterX - worldCenterX));
        }
        else
        {
            dx = -0.2f;
            if ((projCenterX - worldCenterX) > dx)
            {
                dx = (projCenterX - worldCenterX);
            }
        }

        dx *= 10.0f;
        dy *= 100.0f;
    }
    else
    {
        hdVec3 box(0.05f * (m_projection->GetAABB().upper - m_projection->GetAABB().lower));
        hdVec3 diff = (keyBlock->GetWorldCenter() - m_projection->GetWorldCenter());
        hdVec3 mag(fabs(diff.x), fabs(diff.y), 0.0f);

        mag.x = (mag.x < box.x) ? 0.0f : mag.x - box.x;
        mag.y = (mag.y < box.y) ? 0.0f : mag.y - box.y;

        dx = (diff.x > 0.0f) ? -mag.x : mag.x;
        dy = (diff.y < 0.0f) ? -mag.y : mag.y;

        dx *= 5.0f;
        dy *= 5.0f;
    }
    PanProjection(0.0f, 0.0f, dx, dy);
    ZoomProjection(1.0f, 1.0f,
                   0.0f, 0.0f,
                   -1.0f, -1.0f,
                   0.0f, 0.0f);
}
Esempio n. 10
0
File: Run.cpp Progetto: segrax/sgbb
bool _d2Run::Update(float Lag) {
	vector<item>::iterator inventoryIt;

	if(ticksDiff > 0.35f) {

		if( beltPotionsRejuve.size() < 8) {
			if( inventoryPotionsRejuve.size() > 0) {

				if( transferItem.Id == 0) {
					for(inventoryIt = inventoryPotionsRejuve.begin(); inventoryIt != inventoryPotionsRejuve.end(); inventoryIt++) {
						 
						if(inventoryIt->pickupAttempted == false) {
							transferItem = *inventoryIt;
							inventoryIt->Id = 0;
							
							Core->itemToBelt( transferItem );

							inventoryIt->pickupAttempted = true;

							ticksEnd = GetTickCount();
							return true;
						}

					}	// for
			
				 
				}	else	{ // transferItem.id == 0
					transferCount++;
					
					if(transferCount > 10) {
						transferItem.Id = 0;
						ticksEnd = GetTickCount();
						return true;
					}

						ticksEnd = GetTickCount();
						return true;
				 }

			 }	// inventoryPotions
		 }

	 }	// ticksDiff >0.2

	 if(waitTimer && ticksDiff > 0.10f) {
		waitTimer--;

		ticksEnd = GetTickCount();
		return true;
	 }

	// 0 is right hand
	if(skillTargetID[0] != 0 || skillTargetID[1] != 0) {

		// Check our skills
		// Right Hand
		if(skillCurrentID[0] != skillTargetID[0]) {

			if(skillCounter[0]++ == 0) {

				Core->SkillSelect( skillTargetID[0], false);
				ticksEnd = GetTickCount();

			} else {
				if(skillCounter[0] > 1000) {
					skillCounter[0] = 0;
					//Core->GameOver("Right Skill change failed!", true);
				}
				return true;
			}

			attackRecast = false;
			return true;
		}	// skillCurrentID[0]

		// Left Hand
		if(skillCurrentID[1] != skillTargetID[1]) {
			if(skillCounter[1]++ == 0) {

				Core->SkillSelect( skillTargetID[1], true);
				ticksEnd = GetTickCount();

			} else {
				if(skillCounter[1] > 1000) {
					skillCounter[1] = 0;
					//Core->GameOver("Left Skill change failed!", true);
				}
				return true;
			}
			
			attackRecast = false;
			return true;

		}	//skillCurrentID[1]

	}	// TargetIDs != 0

	if(ticksDiff > 0.20f && pickItems.size() > 0 && pickTime && pickingItem.Id == 0) {
		if(pickupTele && !teleporting)
			pickupTele = false;

		if(!teleporting && !pickupTele)
			if(itemsPickup()) {
				ticksEnd = GetTickCount();
				return true;
			}
	}

	if(groundItems.size() > 0 || pickingItem.Id) {
		item Item;

		if(pickupTele && !teleporting)
			pickupTele = false;

		if(ticksDiff > 0.20f && !teleporting && !pickupTele) {
			
			if(pickingItem.Id == 0) {

				for(size_t i = 0; i < groundItems.size(); i++) {

					// Need to clear this flag at the end of the monster waves
					if(groundItems[i].pickupAttempted)
						continue;


					strTmp.str("");
					strTmp << "Picking Up ";

					if( !Item.Id )
						if(groundItems[i].BaseItem == "rvl") {

							if(inventoryPotionsRejuve.size() < 5) {
								
								Item = groundItems[i];

								strTmp << "Rejuvination Potion";
								if(!Core->WithinRangePick( Item.Pos.xPos, Item.Pos.yPos ) ) {
									Item.Id = 0;
									teleSet( Item.Pos.xPos, Item.Pos.yPos, false );
									pickupTele = true;
									return true;
								}
							}

						}

					if( !Item.Id && beltPotionsHealth.size() < 4) 
						if(groundItems[i].BaseItem == "hp5") {
							Item = groundItems[i];
							strTmp << "Health Potion";
							if(!Core->WithinRangePick( Item.Pos.xPos, Item.Pos.yPos ) ) {
								Item.Id = 0;
								continue;
							}
						}


					if( !Item.Id && beltPotionsMana.size() < 4)
						if(groundItems[i].BaseItem == "mp5") {
							Item = groundItems[i];
							strTmp << "Mana Potion";
							if(!Core->WithinRangePick( Item.Pos.xPos, Item.Pos.yPos ) ) {
								Item.Id = 0;
								continue;
							}
						}

					if(Item.Id) {
						groundItems[i].pickupAttempted = true;

						pickedItem = false;
						pickingItem = Item;
						Core->pickItem( Item );
						Core->Debug(2, strTmp.str());

						ticksEnd = GetTickCount();
						return true;
					}
				}	// for

			} else {	// pickingItem != 0
				pickItemFailed++;
				ticksEnd = GetTickCount();

				if(pickItemFailed > 5) {
					//if(groundItems.size())
						//groundItemRemove(pickingItem.Id);

					pickingItem.Id = 0;
					return true;
				}


				return true;
			}

		}	// ticksDiff > 0.20
		
		if(pickingItem.Id != 0)
			return true;

	}	// groundItems.size

	if(ticksDiff > 0.24f || walkComplete || (teleportFirstStep && !cta)) {

		if(followBots) {
			map<DWORD, _d2Player>::iterator Player;

			if(followMode == 0) {
				
				//if(publicMode)
					playersMuteAll(false);

			}	// flowMode = 0

			//if(followMode == 1)
				//Core->SpeakToAll("1");

			if(followAllow)
				if(followMode == 2)
					Core->SpeakToAll("follow");

			if(followMode == 3)
				Core->SpeakToAll("precast");

			//if(followMode == 4)
			//	Core->SpeakToAll("!bo");

			// Check all bounds just incase
			if(followMode >= 4 || followMode < 0) {
				followMode = 0;
				followBots = false;
			}
			
			
			followMode++;
			ticksEnd = GetTickCount();
			return true;
		}	// followBots


		if(Running) {

			if(purchasing && purchaseComplete) {
				
				if(purchaseAmount--) {
					purchaseComplete = false;
					shoppingPurchasing = true;

					Core->TownPurchaseItem( unitMalah, purchaseItem, false );
					ticksEnd = GetTickCount();
					return true;

				} else {
					stepTown++;

					purchasing = false;
					shoppingPurchasing = false;

					ticksEnd = GetTickCount();
					return true;
				}

			} else if (purchasing && !purchaseComplete)	 {// purchasing
				
				return true;
			}

			if(!town && cta) {
				CTARun();
				ticksEnd = GetTickCount();
				return true;
			}	// !town && cta

			// CTAing before out of town
			if(town && cta) {
				if(currentStep == 0) {
					Core->GameOver("CTA in town!", false);
					return true;
				} else
					town = false;
			}

			if(portalCasting) {
				// Make it wait 3 seconds before rechucking
				if(!portalCast || ticksDiff > 4.0f) {
					portalCast = true;
					ThrowTP();
				}
				//ticksEnd = GetTickCount();
				return true;
			}	// portalCasting

		}	// Running


		if(interacting) {

			currentLevel = GetCurrentLevel();
			if(currentLevel)
				if(currentLevel->dwLevelNo == LevelTarget) {

					Sleep(100);
					if(cMap.GenerateMap() == false)
						return true;

					Core->AllowPlayerReassign();
					playerStop();					
					currentStep++;

					groundItems.clear();
					LevelTarget = 0;
					interacting = false;
					interactingCount = 0;

				} else
					interactingCount++;
			
				if(interactingCount > 5) {
					Core->Debug(0, "Interaction failed");
					interactingCount = 0;

					interacting = false;
				}

			free(currentLevel);
			ticksEnd = GetTickCount();
			return true;
		}	// Interacting


		if(Running && walking) {
			if(walkComplete) {
				
				walkComplete = false;

				if(walkStep == 0) {
					Core->playerMove( walkSteps[walkStep].X, walkSteps[walkStep].Y );
					ticksEnd = GetTickCount();
					return true;
				}

			} else {
				walkFailCounter++;

				if(walkFailCounter > 6) {
					walkFailCounter = 0;
					walkStep++;					

					if(walkSteps[walkStep].X == 0) {
						
						walkComplete = false;
						walkStep--;
						Hero->posX = walkSteps[walkStep].X;
						Hero->posY = walkSteps[walkStep].Y;

						playerStop();
						
						Core->playerMove(walkSteps[walkStep].X, walkSteps[walkStep].Y);
						walkCompleted(walkSteps[walkStep].X, walkSteps[walkStep].Y );

						ticksEnd = GetTickCount();
						return true;
					}


				}

				if(walkFailCounter == 0 || walkFailCounter == 5 || walkFailCounter == 10 || walkFailCounter == 15)
					Core->playerMove( walkSteps[walkStep].X, walkSteps[walkStep].Y );

				walkComplete = false;
				ticksEnd = GetTickCount();
			}
			
			return true;
		}	// Running/Walking
		
		if(teleporting || teleportMoving) {
			if(ticksDiff > 0.30f || teleportFirstStep) {

				teleportFirstStep = false;

				if(teleStep >= teleSteps) {
					teleportTimeout++;

					if(( teleSteps > 1 && teleportTimeout > 150) || (teleportTimeout > 250)) {
						Core->Debug(0, "Teleport Timeout");
						teleportTimeout = 0;
						teleStep = teleportCompleted + 1;
						teleFail++;

						if(telePath[ teleStep ].x == 0 || telePath[ teleStep ].y == 0) {
							teleStep--;
							if(teleStep < 0)
								teleStep = 0;
						}

						teleportMoving = true;

						if(teleFail > 3) {
							Core->Debug(0, "Teleport Failed");
							teleporting = false;
							teleportMoving = false;
							teleportCompleted = 0;

							teleFail = 0;
							if(teleAbort) {
								gameTeleTimeout++;
								Core->GameOver("Teleporting Failed!", true);
							}

							return true;
						}

						return true;
					} else
						return true;
				}	//telestep

				if(!teleportMoving) {
					teleportTimeout++;

					if(teleportTimeout > 300) {
						teleportTimeout = 0;
						//teleporting = false;
						teleportMoving = true;
						teleStep = teleportCompleted + 1;
					}

					return true;
				}

				if(telePath[ teleStep ].x == 0 || telePath[ teleStep ].y == 0) {
					//teleporting = false;
					teleportMoving = false;	// This basically means we are waiting for us to arrive at our destination
					//teleSteps = 0;
					teleFail++;
					if(teleFail >= 3) {
						Core->Debug(0, "Teleport Failed");
						teleporting = false;
						teleportMoving = false;
						teleportCompleted = 0;
						teleStep = 0;
						teleFail = 0;
					}
					return true;
				}

				Core->RightSkillFire( (WORD) telePath[ teleStep ].x, (WORD) telePath[ teleStep ].y );
				teleStep++;
				ticksEnd = GetTickCount();
				
			}	// ticksdiff
			
			
			return true;
		}	// teleporting

		if(ticksDiff > 0.30f) {
			if(town) {
				Running = true;
				Town();
				ticksEnd = GetTickCount();
				return true;
			}	// Town
		
		}	// ticksDiff (0.30)
	}

	float ticksDiffStart;
	ticksDiffStart =  ((float) (ticksStartup - ticksEnd)) / 1000;

	if(ticksDiffStart > 10.0f) {

		if(firstLoad) {
			
			EnableDebugPriv();

			if(!cMap.InitMemory("Diablo II", D2WindowTitle)) {
				//Quit = true;
				//Paused = true;	
				//Core->Debug(0, "Init memory Failed!");
				return true;
			} else {

				firstLoad = false;

				return true;
			}
		}

		currentLevel = GetCurrentLevel();
		if(currentLevel) {
			if(currentLevel->dwLevelNo == 109) {	// 109 = harrogath		
				town = true;		
			} else {
				if(town)
					firstTownLeave = true;

				town = false;
			}

			free(currentLevel);


			if(town && (currentStep > 0)) {
				if(realmCreateNewGame == true)
					return true;

				if(!manualMode)
					Core->GameOver("Found ourselves in town mid run!", true);
				
				Running = false;

				return true;
			}

		}
		
	} else // ticksdiffstart
		ticksEnd = GetTickCount();

	return false;
}