Example #1
0
CExplosion::CExplosion(CMap &map, const Ogre::Vector2 &vCenter, EExplosionTypes eExplosionType)
    :
    CAnimatedSprite(map,
                   CIDGenerator::nextID("Explosion_"),
                   map.getExplosionsEntity(),
                   &map,
                   map.get2dManager(),
                   vCenter - EXPLOSION_RELATIVE_OFFSET[eExplosionType],
                   EXPLOSION_SIZES[eExplosionType]),
    m_fFadingTimer(-1) {
    setType(eExplosionType);

    init(1, 1);

    CSpriteTexture::EMirrorTypes eMirrorType = CSpriteTexture::MIRROR_NONE;

    if (m_uiType == ET_BOLT) {
        setupAnimation(0, "bolt_explosion", 5, eMirrorType, &getBoltTexture);
    }
    else if (m_uiType == ET_BOMB) {
        m_vPosition += Ogre::Vector2(0, 0.4);
        setupAnimation(0, "bomb_explosion", 14, eMirrorType, &getBombTexture);
    }
    else if (m_uiType == ET_GREEN_MONSTER) {
        setupAnimation(0, "explosion", 7, eMirrorType, &getEnemyTexturePath<0>);
    }
    else if (m_uiType == ET_KNIGHT) {
        setupAnimation(0, "explosion_right", 5, eMirrorType, &getEnemyTexturePath<1>);
    }
    else if (m_uiType == ET_BEAR) {
        setupAnimation(0, "explosion_right", 1, eMirrorType, &getEnemyTexturePath<2>);
    }
    else if (m_uiType == ET_GHOST) {
        setupAnimation(0, "explosion_right", 4, eMirrorType, &getEnemyTexturePath<3>);
    }
    else if (m_uiType == ET_DARK_MAGICAN) {
        setupAnimation(0, "explosion_right", 4, eMirrorType, &getEnemyTexturePath<4>);
    }
    else if (m_uiType == ET_SANTA) {
        setupAnimation(0, "explosion_right", 9, eMirrorType, &getEnemyTexturePath<5>);
    }
    else if (m_uiType == ET_SKULL) {
        setupAnimation(0, "explosion", 3, eMirrorType, &getSkullTexture);
    }
}
// Create the tray items for the passed document.
void CreateDocumentWorkspace(AcApDocument* pDoc)
{
	// Create the tray items:
	CTrayItem *pTray=new CTrayItem;
	// Create World Tray Item:
	HICON hIcon = (HICON)::LoadImage(_hdllInstance, MAKEINTRESOURCE(IDI_WORLD), IMAGE_ICON, 16, 16, 0);
    int result=pTray->SetIcon(hIcon);
    result=pTray->SetToolTipText(_T("World Icon ToolTip"));
    pTray->Enable(TRUE);
    pTray->SetVisible(TRUE);
	result=pDoc->drawingStatusBar()->Add(pTray);

	// Set this document to map to the first tray item.
	documentTrayMap.SetAt(pDoc,pTray);

    // Create Pie Tray Item:
	pTray=new CTrayItem;
	hIcon = (HICON)::LoadImage(_hdllInstance, MAKEINTRESOURCE(IDI_PIE), IMAGE_ICON, 16, 16, 0);
    result=pTray->SetIcon(hIcon);
    result=pTray->SetToolTipText(_T("Pie Icon ToolTip"));
    pTray->Enable(TRUE);
    pTray->SetVisible(TRUE);
	result=pDoc->drawingStatusBar()->Add(pTray);

    // Create Tree Tray Item:
	pTray=new CTrayItem;
	hIcon = (HICON)::LoadImage(_hdllInstance, MAKEINTRESOURCE(IDI_TREE), IMAGE_ICON, 16, 16, 0);
    result=pTray->SetIcon(hIcon);
    result=pTray->SetToolTipText(_T("Tree Icon ToolTip"));
    pTray->Enable(TRUE);
    pTray->SetVisible(TRUE);
	result=pDoc->drawingStatusBar()->Add(pTray);

	// Create a Pane Item with Text...
	CPaneItem *pPane=new CPaneItem;
	result=pPane->SetToolTipText(_T("Pane Item Tooltip"));
	pPane->Enable(TRUE);
	pPane->SetVisible(TRUE);
	result=pPane->SetStyle(ACSB_POPOUT);
	result=pPane->SetText(_T("Pane Item"));
	result=pPane->SetMinWidth(pDoc->drawingStatusBar()->GetTextWidth(_T("Pane Item")));
	result=pDoc->drawingStatusBar()->Add(pPane);
    
	// Create a Pane Item with an Icon...
	pPane=new CPaneItem;
	result=pPane->SetToolTipText(_T("Pane Icon Item Tooltip"));
	pPane->Enable(TRUE);
	result=pPane->SetStyle(ACSB_POPOUT);
	pPane->SetVisible(TRUE);
	hIcon = (HICON)::LoadImage(_hdllInstance, MAKEINTRESOURCE(IDI_WORLD), IMAGE_ICON, 16, 16, 0);
    result=pPane->SetIcon(hIcon);
	result=pDoc->drawingStatusBar()->Add(pPane);
	
	// Create a status bar menu item...this replaces the default menu item (the small black triangle on the lower right of the doc window).
	CMenuPaneItem *pMenuPane=new CMenuPaneItem;
	result=pDoc->drawingStatusBar()->SetStatusBarMenuItem(pMenuPane);
}
Example #3
0
void CMainMap::SetFixImage(const char *filename)
{
    CWindow*    pw;
    CMap*       pm;

    pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
    if (pw == nullptr)
        return;

    pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
    if (pm == nullptr)
        return;

    pw->DeleteControl(EVENT_OBJECT_MAPZOOM);
    m_bFixImage = true;

    pm->SetFixImage(filename);
}
Example #4
0
void COnCollision::init(const CMap &map) {
  m_pEntity = map.getChildRecursive(m_sSrcID);
  if (!m_pEntity) {
    throw Ogre::Exception(0, "An entity with id " + m_sSrcID + " was not found.", __FILE__);
  }
  else {
    Ogre::LogManager::getSingleton().logMessage("Entity with id " + m_sSrcID + " set as collisions object.");
  }
}
Example #5
0
void CMainMap::MapEnable(bool bEnable)
{
    CWindow*    pw;
    CMap*       pm;
    CSlider*    ps;

    pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
    if (pw == nullptr)
        return;

    pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
    if (pm != nullptr)
        pm->SetEnable(bEnable);

    ps = static_cast<CSlider*>(pw->SearchControl(EVENT_OBJECT_MAPZOOM));
    if (ps != nullptr)
        ps->SetState(STATE_ENABLE, bEnable);
}
Example #6
0
/**
**  Regenerate forest.
**
**  @param pos  Map tile pos
*/
void CMap::RegenerateForestTile(const Vec2i &pos)
{
	Assert(Map.Info.IsPointOnMap(pos));
	CMapField &mf = *this->Field(pos);

	if (mf.Tile != this->Tileset.RemovedTree) {
		return;
	}

	//  Increment each value of no wood.
	//  If grown up, place new wood.
	//  FIXME: a better looking result would be fine
	//    Allow general updates to any tiletype that regrows

	const unsigned int occupedFlag = (MapFieldWall | MapFieldUnpassable | MapFieldLandUnit | MapFieldBuilding);
	++mf.Value;
	if (mf.Value < ForestRegeneration) {
		return;
	}
	mf.Value = ForestRegeneration;
	if ((mf.Flags & occupedFlag) || pos.y == 0) {
		return;
	}
	CMapField &topMf = *(&mf - this->Info.MapWidth);
	if (topMf.Tile == this->Tileset.RemovedTree
		&& topMf.Value >= ForestRegeneration
		&& !(topMf.Flags & occupedFlag)) {
		DebugPrint("Real place wood\n");
		topMf.Tile = this->Tileset.TopOneTree;
		topMf.Value = 0;
		topMf.Flags |= MapFieldForest | MapFieldUnpassable;

		mf.Tile = this->Tileset.BotOneTree;
		mf.Value = 0;
		mf.Flags |= MapFieldForest | MapFieldUnpassable;
		if (Map.IsFieldVisible(*ThisPlayer, pos)) {
			MarkSeenTile(pos);
		}
		const Vec2i offset(0, -1);
		if (Map.IsFieldVisible(*ThisPlayer, pos + offset)) {
			MarkSeenTile(pos);
		}
	}
}
Example #7
0
bool CArea::onLoad(const std::string & file, int sizeX, int sizeY) {
		mMapSize.x = sizeX; mMapSize.y = sizeY;
    mapList.clear();

    FILE* fileHandle = fopen(file.c_str(), "r");

    if(fileHandle == NULL) {
        return false;
    }

    char tilesetFile[255] = "";

    fscanf(fileHandle, "%s\n", tilesetFile);

		//Load texture for the area
		mTilesetTexture.setID(RESOURCE_DIR + std::string("/") + tilesetFile);

    fscanf(fileHandle, "%d\n", &areaSize);

    for(int X = 0;X < areaSize;X++) {
        for(int Y = 0;Y < areaSize;Y++) {
            std::string mapPath = "";
						mapPath.append(RESOURCE_DIR"/");
						char mapfile[255];
            fscanf(fileHandle, "%s ", mapfile);
						mapPath.append(mapfile);
            CMap tempMap;
            if(tempMap.onLoad(mapPath,mMapSize.x,mMapSize.y) == false) {
                fclose(fileHandle);
								ELOG() << "Could not load map (" << mapPath << ")"  << std::endl;
                return false;
            }

						tempMap.setTexture(mTilesetTexture);

            mapList.push_back(tempMap);
        }
        fscanf(fileHandle, "\n");
    }

    fclose(fileHandle);

    return true;
}
// Unload this application. Unregister all objects
// registered in InitApplication.
void UnloadApplication()
{
	// NOTE: DO NOT edit the following lines.
	//{{AFX_ARX_EXIT
	//}}AFX_ARX_EXIT
	
	acedRegCmds->removeGroup(_T("ADSK"));

	documentTrayMap.RemoveAll();
}
// 把选中区域转换为绝对排列字符串
CString CGraphInstrumentList::ConvertSelectAreaToAbsoluteSpreadString(CRect* pSelectAreaIndex)
{
	CString strAbsoluteSpread = "";
	CString strLine, strPoint;
	int iPointNb, iPointNbStart, iPointNbEnd;
	int iLineNb;
	CMap<int, int, CString, CString> oLineNbMap;

	for(int i = pSelectAreaIndex->top; i <= pSelectAreaIndex->bottom; i++)
	{
		// 得到图形区列索引对应的测线号
		iLineNb = GetLineNbByRowIndex(i);
		if(iLineNb > 0)	// 测线有效
		{
			iPointNbStart = GetPointNbByColumnIndex(pSelectAreaIndex->left);	// 得到起始测点
			iPointNbEnd = GetPointNbByColumnIndex(pSelectAreaIndex->right);	// 得到终止测点
			if((iPointNbStart > 0) && (iPointNbEnd > 0))	// 测点有效
			{
				if(iPointNbStart > iPointNbEnd)
				{
					iPointNb = iPointNbStart;
					iPointNbStart = iPointNbEnd;
					iPointNbEnd = iPointNb;
				}
				strPoint.Format("%d-%d", iPointNbStart, iPointNbEnd);	// 测点字符串
				strLine.Format("%d:%s;", iLineNb, strPoint);	// 测线字符串
				oLineNbMap.SetAt(iLineNb, strLine);	// 加入索引表
			}
		}
	}
	POSITION pos = oLineNbMap.GetStartPosition();
	while(NULL != pos)
	{
		oLineNbMap.GetNextAssoc(pos, iLineNb, strLine);
		strAbsoluteSpread = strAbsoluteSpread + strLine;	// 链接测线字符串
	}
	if(strAbsoluteSpread.GetLength() > 0)
	{
		strAbsoluteSpread = strAbsoluteSpread.Left(strAbsoluteSpread.GetLength() - 1);	// 去掉最后一个字符“;”
	}
	oLineNbMap.RemoveAll();
	return strAbsoluteSpread;
}
Example #10
0
/**
**  Regenerate forest.
**
**  @param pos  Map tile pos
*/
void CMap::RegenerateForestTile(const Vec2i &pos)
{
	Assert(Map.Info.IsPointOnMap(pos));
	CMapField &mf = *this->Field(pos);

	if (mf.getGraphicTile() != this->Tileset->getRemovedTreeTile()) {
		return;
	}

	//  Increment each value of no wood.
	//  If grown up, place new wood.
	//  FIXME: a better looking result would be fine
	//    Allow general updates to any tiletype that regrows

	const unsigned int occupedFlag = (MapFieldWall | MapFieldUnpassable | MapFieldLandUnit | MapFieldBuilding);
	++mf.Value;
	if (mf.Value < ForestRegeneration) {
		return;
	}
	mf.Value = ForestRegeneration;
	if ((mf.Flags & occupedFlag) || pos.y == 0) {
		return;
	}
	const Vec2i offset(0, -1);
	CMapField &topMf = *(&mf - this->Info.MapWidth);
	if (topMf.getGraphicTile() == this->Tileset->getRemovedTreeTile()
		&& topMf.Value >= ForestRegeneration
		&& !(topMf.Flags & occupedFlag)) {
		DebugPrint("Real place wood\n");
		topMf.setTileIndex(*Map.Tileset, Map.Tileset->getTopOneTreeTile(), 0);
		topMf.setGraphicTile(Map.Tileset->getTopOneTreeTile());
		topMf.playerInfo.SeenTile = topMf.getGraphicTile();
		topMf.Value = 0;
		topMf.Flags |= MapFieldForest | MapFieldUnpassable;
		UI.Minimap.UpdateSeenXY(pos + offset);
		UI.Minimap.UpdateXY(pos + offset);


		mf.setTileIndex(*Map.Tileset, Map.Tileset->getBottomOneTreeTile(), 0);
		mf.setGraphicTile(Map.Tileset->getBottomOneTreeTile());
		mf.playerInfo.SeenTile = mf.getGraphicTile();
		mf.Value = 0;
		mf.Flags |= MapFieldForest | MapFieldUnpassable;
		UI.Minimap.UpdateSeenXY(pos);
		UI.Minimap.UpdateXY(pos);
		if (mf.playerInfo.IsTeamVisible(*ThisPlayer)) {
			MarkSeenTile(mf);
		}
		if (Map.Field(pos + offset)->playerInfo.IsTeamVisible(*ThisPlayer)) {
			MarkSeenTile(topMf);
		}
		FixNeighbors(MapFieldForest, 0, pos + offset);
		FixNeighbors(MapFieldForest, 0, pos);
	}
}
Example #11
0
void CMainMap::DimMap()
{
    CWindow*    pw;
    CMap*       pm;
    CSlider*    ps;
    Math::Point     pos, dim;
    float       value;

    pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
    if (pw == nullptr)
        return;
    pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
    if (pm == nullptr)
        return;

    pm->SetState(STATE_VISIBLE, (m_mapMode != 0));

    dim.x = 100.0f/640.0f;
    dim.y = 100.0f/480.0f;
    pos.x = 540.0f/640.0f;
    pos.y =   0.0f/480.0f;
    pm->SetPos(pos);
    pm->SetDim(dim);

    ps = static_cast<CSlider*>(pw->SearchControl(EVENT_OBJECT_MAPZOOM));
    if (ps != nullptr) {
        ps->SetState(STATE_VISIBLE, (m_mapMode != 0));

        dim.x = SCROLL_WIDTH;
        dim.y =  66.0f / 480.0f;
        pos.x = 523.0f / 640.0f;
        pos.y =   3.0f / 480.0f;
        ps->SetPos(pos);
        ps->SetDim(dim);

        value = pm->GetZoom();
        value = (value-ZOOM_MIN) / (ZOOM_MAX-ZOOM_MIN);
        value = powf(value, 0.5f);
        ps->SetVisibleValue(value);
        ps->SetArrowStep(0.2f);
    }
}
Example #12
0
float CMainMap::GetZoomMap()
{
    CWindow*    pw;
    CMap*       pm;
    CSlider*    ps;

    pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
    if (pw == nullptr)
        return ZOOM_MIN;

    pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
    if (pm == nullptr)
        return ZOOM_MIN;

    ps = static_cast<CSlider*>(pw->SearchControl(EVENT_OBJECT_MAPZOOM));
    if (ps == nullptr)
        return ZOOM_MIN;

    return pm->GetZoom();
}
Example #13
0
extern "C" int main(int argc, char** argv)  { 
    
    SDL_Init( SDL_INIT_EVERYTHING );                                            //Inicjacja SDL
    ekran = SDL_SetVideoMode( 800, 600, 32, SDL_SWSURFACE);                     //Ustawienie sterownika okna SDL
    CMap *world = new CMap("data/mapa.japierdole");                             //Konstruktor œwiata
    CPlayer *player = new CPlayer( "data/grog.japierdole",150,150,1);           //Konstruktor gracza
    CEvents *events = new CEvents;                                              //Konstruktor pêtli
    
    player->draw();                                                             //rysowanie gracza
    world->draw();                                                              //rysowanie œwiata
    SDL_Flip( ekran );                                                          //"przerzucenie" ekranu - podwójny bufor
    events->loop();                                                             //pêtla
	
	delete world;                                                               //Destruktor œwiata
	delete player;                                                              //destruktor gracza
	delete events;                                                              //destruktor pêtli
    SDL_Quit();                                                                 //wy³¹cza SDL
    
    return 0;
}
Example #14
0
void Init(HWND hWnd)
{
    // Set our global window handle to our main window
    g_hWnd = hWnd;

    // Create our double buffering for each window
    g_Buffer.CreateDoubleBuffering(hWnd);
    g_ToolBuffer.CreateDoubleBuffering(g_hWndTool);

    // Set the map to default
    g_Map.SetDefault();

    // Load the tiles into the global lists and then get the scroll bar max scroll position
    g_ScrollInfo.nMax = LoadTiles();

    // By default set the current tile type to map tiles
    g_Map.SetCurrentType(TILE_TYPE);

    // Set our current map to ....  our current map :)
    g_pCurrentMap = &g_Map;

    // Initialize the scroll bar information
    g_ScrollInfo.cbSize = sizeof(SCROLLINFO);
    g_ScrollInfo.nMin = 0;
    g_ScrollInfo.nPage = 1;
    g_ScrollInfo.fMask = SIF_PAGE | SIF_RANGE;
    SetScrollInfo(g_hWndTool, SB_VERT, &g_ScrollInfo, FALSE);


//////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** ////////////////////

    // Here we set the current pen to red for drawing our exit rectangles
    g_Buffer.SetPen(PS_SOLID,2,RGB(255,0,0));

//////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** ////////////////////


    // Set the backbuffer to black first (This clears the backbuffer)
    g_Buffer.ClearScreen(BLACK_BRUSH);
    g_ToolBuffer.ClearScreen(BLACK_BRUSH);
}
Example #15
0
void CSizeableDlg::OnSizeControl(CWnd &stWnd, int cx, int cy, UINT nLocks)
{
	static CMap <CWnd*, CWnd*, WND_SIZE_DATA, WND_SIZE_DATA&> mapWnds;

	if (!IsWindow(stWnd))
		return;

	// check if this window was already measured by us
	WND_SIZE_DATA stSD;
	if (mapWnds.Lookup(&stWnd, stSD))
	{
		CRect stRect = stSD.stFirst;

		if (nLocks & 2)
		{
			stRect.right += cx - stSD.cx_now;
			if (nLocks & 1)
				stRect.left += cx - stSD.cx_now;
		}

		if (nLocks & 8)
		{
			stRect.bottom += cy - stSD.cy_now;
			if (nLocks & 4)
				stRect.top += cy - stSD.cy_now;
		}

		stWnd.MoveWindow(&stRect);
	} else
	{
		// this is a new window
		WND_SIZE_DATA stSD;
		stSD.cx_now = cx;
		stSD.cy_now = cy;

		stWnd.GetWindowRect(&stSD.stFirst);
		ScreenToClient(&stSD.stFirst);

		mapWnds.SetAt(&stWnd, stSD);
	}
}
Example #16
0
CObject::CObject(CMap &map,
		 CEntity *pParent,
		 const tinyxml2::XMLElement *pElement) 
  : CAnimatedSprite(map,
		    pParent,
		    &map,
		    map.get2dManager(),
		    pElement,
		    OBJECT_SIZES[IntAttribute(pElement, "type")]) ,
    m_bIsPickable(false) {
  constructor_impl();
}
Example #17
0
bool CWorldServer::DoSkillScript( CCharacter* character, CSkills* thisskill )
{
     try
     {
        if(thisskill==0)
            return false;
        if(thisskill->script==0)
            return false;
        if(thisskill->svalue1==0)
            return false;
        fPoint position = RandInCircle( character->Position->current, 5 );
        CMap* map = MapList.Index[character->Position->Map];
        map->AddMonster( thisskill->svalue1, position, character->clientid );
        return true;
    }
    catch (...)
    {
         Log(MSG_WARNING, "Error in CWorldServer::DoSkillScript( CCharacter* character, CSkills* thisskill )(serverFunctions.cpp)" );
         return false;
    }
}
Example #18
0
bool CGameApp::MsgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	CApp::MsgProc(hwnd, uMsg, wParam, lParam);

	if (uMsg == WM_LBUTTONUP)
	{
		Vec2I position = GetAppCursor()->GetPosition();
		m_Map.Input(position);
	}

	return true;
}
Example #19
0
// Deletes an old clientsocket structure
void CWorldServer::DeleteClientSocket( CClientSocket* thisclient )
{
    DB->QExecute( "UPDATE channels SET connected=%i where id=%i and type=2", ConnectedClients, Config.ServerID );
if(thisclient->player!=NULL)
    {
        CPlayer* player = (CPlayer*) thisclient->player;
        Log( MSG_INFO, "User disconnected (%s)", player->CharInfo->charname );
        CMap* map = MapList.Index[player->Position->Map];
        pthread_mutex_lock( &MapMutex );
        map->RemovePlayer( player );
        pthread_mutex_unlock( &MapMutex );
        delete player;
        player = NULL;
    }
    else
    {
        delete thisclient;
        thisclient = NULL;
    }

}
Example #20
0
void CDlgSpeedTest::Sort()
{
	CMap<DWORD,DWORD,SpeedTestResult,SpeedTestResult> mapTmp;
	CArray<SpeedTestResult,SpeedTestResult> ayTmp;
	for (int i=0; i<m_ayTestResult.GetCount(); i++)
	{
		SpeedTestResult res = m_ayTestResult.GetAt(i);
		if (!res.m_bError)
		{
			mapTmp.SetAt(res.m_result,res);
		}
		else
			ayTmp.Add(res);
	}
	m_ayTestResult.RemoveAll();
	POSITION pos = mapTmp.GetStartPosition();
	DWORD key;
	SpeedTestResult val;
	while (pos)
	{
		mapTmp.GetNextAssoc(pos,key,val);
		m_ayTestResult.Add(val);
	}
	for (int j=0; j<ayTmp.GetCount(); j++)
	{
		m_ayTestResult.Add(ayTmp.GetAt(j));
	}

	for(int i=0; i<m_cList.GetItemCount(); i++)
	{
		CString str;
		str = m_cList.GetItemText(i,0);
		if (FindRes(str))
		{
			m_cList.DeleteItem(i);
			i--;
		}
	}
	ShowRes();
}
bool MapReader1800::load(CMap& map, BinaryFile& mapfile/*, const char* filename*/, ReadType readtype)
{
    read_autofilters(map, mapfile);

    if (readtype == read_type_summary)
        return true;

    map.clearPlatforms();

    // FIXME
    /*cout << "loading map " << filename;

    if (readtype == read_type_preview)
        cout << " (preview)";

    cout << " [Version " << version[0] << '.' << version[1] << '.'
         << version[2] << '.' << version[3] << " Map Detected]\n";*/

    read_tileset(mapfile);

    read_tiles(map, mapfile);
    read_background(map, mapfile);
    read_switches(map, mapfile);
    read_platforms(map, mapfile, readtype == read_type_preview);

    //All tiles have been loaded so the translation is no longer needed
    delete [] translationid;
    delete [] tilesetwidths;
    delete [] tilesetheights;

    read_items(map, mapfile);
    read_hazards(map, mapfile);
    read_eyecandy(map, mapfile);
    read_music_category(map, mapfile);
    read_warp_locations(map, mapfile);
    read_switchable_blocks(map, mapfile);

    if (readtype == read_type_preview)
        return true;

    read_warp_exits(map, mapfile);
    if (!read_spawn_areas(map, mapfile))
        return false;

    if (!read_draw_areas(map, mapfile))
        return false;

    read_extra_tiledata(map, mapfile);
    read_gamemode_settings(map, mapfile);

    return true;
}
Example #22
0
void LoadOrSaveAMap(bool bLoad)
{
	string strMapName = "";		// Create a STL string to read in the input from the user
	char szName[255] = {0};		// Create a traditional string of characters for the file name

	// Get an output handle for the console window and set the cursor position for a prompt
	HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleCursorPosition(hOutput, g_promptPos);

	// To clear the prompt, we just print out a bunch of tabs and then reset the cursor position
	cout << "\t\t\t\t\t\t\t\t\t\t";
	SetConsoleCursorPosition(hOutput, g_promptPos);

	// Get an input handle and set the console window to allow input from the user 
	HANDLE hInput = GetStdHandle(STD_INPUT_HANDLE);			
	SetConsoleMode(hInput, ENABLE_PROCESSED_INPUT | ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT);

	// Below we check if we want to load or save a file, then display the appropriate message
	if(bLoad)
		cout << "Enter a map to Load: ";
	else
		cout << "Enter a map to Save: ";

	// Here we get the map name that we want to save or load
	cin >> strMapName;

	// Then we extract the string from the string class and put it in a normal array or characters
	strcpy(szName, strMapName.c_str());

	// Next we either load or save the map entered by the user, depending on bLoad
	if(bLoad)
		g_Map.Load(szName);
	else
		g_Map.Save(szName);

	// Next, we restore the console mode for getting mouse and keyboard input and redraw the screen
	SetConsoleMode(hInput, ENABLE_PROCESSED_INPUT | ENABLE_MOUSE_INPUT);
	g_Map.Draw();	
}
Example #23
0
CDebugDrawer::CDebugDrawer(CMap &map) {
  m_DebugTextures[DT_PINK] = getTextureInGfx("debug_pink.png");
  m_DebugTextures[DT_BLUE] = getTextureInGfx("debug_blue.png");
  m_DebugTextures[DT_GREEN] = getTextureInGfx("debug_green.png");

  m_pDebugSprite = new CSprite(map,
			       "DebugTile",
			       NULL,
			       &map,
			       map.getDebug2dManager(),
			       Ogre::Vector2::ZERO,
			       Ogre::Vector2::UNIT_SCALE);
}
Example #24
0
void Init(HWND hWnd)
{
	// Set our global window handle to our main window
	g_hWnd = hWnd;

	// Create our double buffering our window
	g_Buffer.CreateDoubleBuffering(hWnd);

	// This is where we create the image of our character
	HBITMAP hPlayerImage = g_Buffer.LoadABitmap((LPSTR)kPlayerImage);
	
	// Initialize our player with it's image and position
	g_Player.Init(hPlayerImage, kPlayerStartX, kPlayerStartY);


//////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** ////////////////////

	// Now that we have a party, we need to add the normal player to that party
	g_Player.AddPlayerToParty(&g_Player);

//////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** ////////////////////


	// Init, load and draw the first map file
	g_Map.Load(kStartMap);
	g_Map.SetDrawFlag(true);

	// Here we load then play the starting background music
	if(!g_Music.Init("techno.mod"))
		exit(0);

	g_Music.PlaySong();

	// we need to seed our random number generator (rand()) for moving npcs.
	srand(GetTickCount());

	// Set the backbuffer to black first (This clears the backbuffer)
	g_Buffer.ClearScreen(BLACK_BRUSH);			
}
Example #25
0
void Reporter :: WriteReport ( void )
{
	FILE * pFile = fopen ( "report.txt", "w" );
	ASSERT ( pFile );
	if (pFile == NULL )
		return;

	for ( POSITION pos = m_mapHistory.GetStartPosition(); pos != NULL; )
	{
		CString str;
		CMap<int,int,int,int> *pCount;
		int i;

		m_mapHistory.GetNextAssoc ( pos, str, pCount );

		int c = 0;

		for ( POSITION pos2 = pCount->GetStartPosition(); pos2 != NULL; )
		{
			int t, c2;
			pCount->GetNextAssoc ( pos2, t, c2 );
			c += c2;
		}


//		c /= pCount->GetSize();
		if ( c < 1000 )
			continue;

		fprintf ( pFile, "%s\t", str );
		for ( i = 0; i < m_time; i++ )
		{
			fprintf ( pFile, "%d\t", (*pCount)[i] );
			fflush ( pFile );
		}

		fprintf ( pFile, "\n" );
	}
}
Example #26
0
void CMainMap::ShowMap(bool bShow)
{
    CWindow*    pw;
    CMap*       pm;
    CSlider*    ps;

    pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
    if (pw == nullptr)
        return;

    if (bShow) {
        DimMap();
    } else {
        pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
        if (pm != nullptr)
            pm->ClearState(STATE_VISIBLE);

        ps = static_cast<CSlider*>(pw->SearchControl(EVENT_OBJECT_MAPZOOM));
        if (ps != nullptr)
            ps->ClearState(STATE_VISIBLE);
    }
}
Example #27
0
//LMA: Used for QSD.
CNPC* CMap::GetNPCInMapQSD( UINT id )
{
    for(UINT i=0;i<NPCList.size();i++)
    {
        CNPC* thisNpc = NPCList.at(i);
        if(thisNpc->npctype == id )
            return thisNpc;
    }

    //LMA: If we didn't find the NPC in current map, let's search elsewhere, let's get the good map.
    Log(MSG_WARNING,"NPC %i not found in map %i",id,this->id);
    if (GServer->ListAllNpc.find(id)==GServer->ListAllNpc.end())
    {
        Log(MSG_WARNING,"NPC %i not found ListAllNPC",id);
        return NULL;
    }

    if(GServer->ListAllNpc[id].size()==0)
    {
        Log(MSG_WARNING,"NPC %i found in ListAllNPC but no entry",id);
        return NULL;
    }

    //We use the first entry...
    CMap* thisMap = GServer->MapList.Index[GServer->ListAllNpc[id].at(0)];
    CNPC* thisNpc = thisMap->GetNPCInMapQSD(id);
    if(thisNpc!=NULL)
    {
        Log(MSG_WARNING,"NPC %i found thanks to ListAllNPC in map %i",thisNpc->npctype,GServer->ListAllNpc[id].at(0));
    }
    else
    {
        Log(MSG_WARNING,"NPC %i NOT found thanks to ListAllNPC in map %i",id,GServer->ListAllNpc[id].at(0));
    }


    return thisNpc;
}
//=--------------------------------------------------------------------------=
// CNSAdapter_JavaPlugin::Destroy
//=--------------------------------------------------------------------------=
// This will destroy Java Plug-in instance
//
//result - NS_OK if call succeed
// notes :
//
NS_METHOD
CNSAdapter_JavaPlugin::Destroy()
{
    TRACE("CNSAdapter_JavaPlugin::Destroy\n");
    if (m_pJavaPlugin == NULL)
	return NS_ERROR_NULL_POINTER;

    nsresult res = m_pJavaPlugin->Destroy();

    // Remove from pluginMap when applet is destroyed
    pluginMap.InsertElement((void*)m_pJavaPlugin, NULL);

    return res;
}
Example #29
0
void CKnownFileList::CopyKnownFileMap(CMap<CCKey,const CCKey&,CKnownFile*,CKnownFile*> &Files_Map)
{
	if (!m_Files_map.IsEmpty())
	{
		POSITION pos = m_Files_map.GetStartPosition();
		while (pos)
		{
			CCKey key;
			CKnownFile* cur_file;
			m_Files_map.GetNextAssoc(pos, key, cur_file);
			Files_Map.SetAt(key, cur_file);
		}
	}
}
	void CPowerupManager::GeneratePowerups( const CMap& map )
	{
		int n = 0;
		auto size = map.GetSize();
		switch( CGameMode::GetObjectRate() ) {
			case CGameMode::NO: n = 0;  break;
			case CGameMode::FEW: n = size.first * size.second / 100; break;
			case CGameMode::NORMAL: n = size.first * size.second / 75; break;
			case CGameMode::MANY: n = size.first * size.second / 50; break;
			default: n = 0;  break;
		}
		if( initialized && CGameMode::GetObjectChangeModel() == CGameMode::NO_CHANGE ) {
			return;
		}
		if( !initialized || CGameMode::GetObjectChangeModel() == CGameMode::RANDOM ) {
			if( CGameMode::GetObjectChangeModel() == CGameMode::RANDOM ) {
				powerupCoordinates.clear();
			}
			initialized = true;
			for( int i = 0; i < n; ++i ) {
				int x, y;
				do {
					x = std::rand() % map.GetSize().first;
					y = std::rand() % map.GetSize().second;
				} while( map.GetField()[y][x] != ROAD || powerups.find( CCoordinates( x, y ) ) != powerups.end() );
				powerupCoordinates.push_back( CCoordinates( x, y ) );
			}
		}
		powerups.clear();
		for( auto coordinates : powerupCoordinates ) {
			int type;
			do {
				type = std::rand() % 8;
			} while( type == NONE );
			powerups[Core::CCoordinates( coordinates.x, coordinates.y )] = PowerupType( type );
		}
	}