当前位置: 首页>>代码示例>>C++>>正文


C++ ListIter类代码示例

本文整理汇总了C++中ListIter的典型用法代码示例。如果您正苦于以下问题:C++ ListIter类的具体用法?C++ ListIter怎么用?C++ ListIter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ListIter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: while

void
UVMapView::SelectInverse()
{
    ListIter<Poly> iter = polys;
    while (++iter) {
        Poly* p = iter.value();

        if (p->material != material)
            continue;

        for (int i = 0; i < p->nverts; i++) {
            WORD  p_index = iter.index();
            DWORD value   = (p_index << 16) | i;

            bool contains = false;
            auto svi = selverts.begin();
            for (; svi != selverts.end(); ++svi) {
                if (*svi == value) {
                    contains = true;
                    break;
                }
            }

            if (contains)
                selverts.erase(svi);
            else
                selverts.push_back(value);
        }
    }
}
开发者ID:Banbury,项目名称:starshatter-open,代码行数:30,代码来源:UVMapView.cpp

示例2:

bool
Screen::Resize(int w, int h)
{
	// scale all root-level windows to new screen size:

	ListIter<Window> iter = window_list;
	while (++iter) {
		Window* win = iter.value();

		double  w_x = win->GetRect().x / (double) width;
		double  w_y = win->GetRect().y / (double) height;
		double  w_w = win->GetRect().w / (double) width;
		double  w_h = win->GetRect().h / (double) height;

		Rect    r;

		r.x = (int) (w_x * w);
		r.y = (int) (w_y * h);
		r.w = (int) (w_w * w);
		r.h = (int) (w_h * h);

		win->MoveTo(r);
	}

	width  = w;
	height = h;

	return true;
}
开发者ID:The-E,项目名称:Starshatter-Experimental,代码行数:29,代码来源:Screen.cpp

示例3: SendJoinRequest

void
NetGameClient::ExecFrame()
{
	if (local_player) {
		if (local_player->GetObjID() == 0) {
			SendJoinRequest();
		}

		else if (active) {
			// check health of server:
			NetPeer* server_peer = link->FindPeer(server_id);
			if (server_peer && (NetLayer::GetUTC() - server_peer->LastReceiveTime() > 15)) {
				NetMsg net_disco(0, NET_DISCONNECT, 0, 0, 0);
				DoDisconnect(&net_disco);
			}

			// if server is still there,
			else if (server_peer) {

				// check if any old join announcements still need to be processed:
				ListIter<NetJoinAnnounce> iter = join_backlog;
				while (++iter) {
					NetJoinAnnounce* join_ann = iter.value();

					if (DoJoinBacklog(join_ann)) {
						iter.removeItem();
						delete join_ann;
					}
				}
			}
		}
	}

	NetGame::ExecFrame();
}
开发者ID:The-E,项目名称:Starshatter-Experimental,代码行数:35,代码来源:NetGameClient.cpp

示例4: new

void
ModConfig::EnableMod(const char* name)
{
	if (!name || !*name)
	return;

	Text* mod_name;

	ListIter<Text> iter = disabled;
	while (++iter) {
		Text* t = iter.value();

		if (*t == name) {
			mod_name = t;
			iter.removeItem();
			break;
		}
	}

	if (mod_name) {
		enabled.append(mod_name);

		if (!IsDeployed(*mod_name)) {
			ModInfo* mod_info = new(__FILE__,__LINE__) ModInfo;
			
			if (mod_info->Load(*mod_name) && mod_info->Enable()) {
				mods.append(mod_info);
			}
		}
	}
}
开发者ID:lightgemini78,项目名称:Starshatter-Rearmed,代码行数:31,代码来源:ModConfig.cpp

示例5: fopen_s

void
NetClientConfig::Save()
{
	FILE* f;
	fopen_s(&f, "client.cfg", "w");
	if (f) {
		fprintf(f, "CLIENT_CONFIG\n\n");

		ListIter<NetServerInfo> iter = servers;
		while (++iter) {
			NetServerInfo* server = iter.value();

			if (server->save) {
				int port = (int) server->port;
				fprintf(f, "server: {\n");
				fprintf(f, "  name: \"%s\",\n", (const char*) server->name);
				fprintf(f, "  addr: \"%s\",\n", (const char*) server->hostname);
				fprintf(f, "  port: %d,\n",                   port);

				if (server->password.length())
				fprintf(f, "  pass: \"%s\",\n", (const char*) server->password);

				fprintf(f, "}\n\n");
			}
		}

		fclose(f);
	}
}
开发者ID:The-E,项目名称:Starshatter-Experimental,代码行数:29,代码来源:NetClientConfig.cpp

示例6: type

System::System(const System& s)
: type(s.type), id(s.id), ship(0), subtype(s.subtype), status(s.status),
availability(s.availability), safety(s.safety), stability(s.stability), 
crit_level(s.crit_level), net_avail(-1.0f),
mount_rel(s.mount_rel), radius(s.radius), safety_overload(0.0f),
hull_factor(s.hull_factor), energy(s.energy), capacity(s.capacity),
sink_rate(s.sink_rate),  power_level(s.power_level), power_flags(s.power_flags),
source_index(s.source_index), power_on(s.power_on), max_value(s.max_value),
explosion_type(s.explosion_type), name(s.name), abrv(s.abrv), design(s.design),
emcon(s.emcon)
{
    if (design) {
        // cast-away const
        ListIter<Component> c = (List<Component>&) s.components;
        while (++c) {
            Component* comp = new(__FILE__,__LINE__) Component(*(c.value()));
            comp->SetSystem(this);
            components.append(comp);
        }
    }

    emcon_power[0] = s.emcon_power[0];
    emcon_power[1] = s.emcon_power[1];
    emcon_power[2] = s.emcon_power[2];
}
开发者ID:Banbury,项目名称:starshatter-open,代码行数:25,代码来源:System.cpp

示例7: while

void
WeaponGroup::PowerOn()
{
    ListIter<Weapon> w = weapons;
    while (++w)
        w->PowerOn();
}
开发者ID:The-E,项目名称:Starshatter-Experimental,代码行数:7,代码来源:WeaponGroup.cpp

示例8: SelectTarget

void
GroundAI::ExecFrame(double secs)
{
    const int exec_period = 1000;

    if ((int) Game::GameTime() - exec_time > exec_period) {
        exec_time = (int) Game::GameTime();
        SelectTarget();
    }

    if (ship) {
        Shield* shield = ship->GetShield();

        if (shield)
        shield->SetPowerLevel(100);

        ListIter<WeaponGroup> iter = ship->Weapons();
        while (++iter) {
            WeaponGroup* group = (WeaponGroup*) iter.value();

            if (group->NumWeapons() > 1 && group->CanTarget(Ship::DROPSHIPS))
            group->SetFiringOrders(Weapon::POINT_DEFENSE);
            else
            group->SetFiringOrders(Weapon::AUTO);

            group->SetTarget((Ship*) target, 0);
        }

        if (carrier_ai)
        carrier_ai->ExecFrame(secs);
    }
}
开发者ID:Banbury,项目名称:starshatter-open,代码行数:32,代码来源:GroundAI.cpp

示例9: while

void
NetClientDlg::ShowServers()
{
    if (!config || !lst_servers) return;

    lst_servers->ClearItems();
    lst_servers->SetSelectedStyle(ListBox::LIST_ITEM_STYLE_FILLED_BOX);
    lst_servers->SetLeading(2);

    int i = 0;
    ListIter<NetServerInfo> iter = config->GetServerList();
    while (++iter) {
        NetServerInfo* info = iter.value();

        lst_servers->AddItemWithData(info->name, (DWORD) i);
        lst_servers->SetItemText(i, 1, info->type);
        lst_servers->SetItemText(i, 2, info->password);
        lst_servers->SetItemText(i, 3, Game::GetText("NetClientDlg.offline"));
        lst_servers->SetItemText(i, 4, "0");
        lst_servers->SetItemText(i, 5, Game::GetText("NetClientDlg.not-avail"));

        i++;
    }

    ping_index   = 0;
    server_index = -1;

    if (btn_host)  btn_host->SetEnabled(false);
    if (btn_join)  btn_join->SetEnabled(false);
    if (btn_del)   btn_del->SetEnabled(false);
}
开发者ID:Banbury,项目名称:starshatter-open,代码行数:31,代码来源:NetClientDlg.cpp

示例10:

void
ModConfig::FindMods()
{
	disabled.destroy();

	DataLoader* loader = DataLoader::GetLoader();

	if (loader) {
		loader->UseFileSystem(true);
		loader->ListFiles("*.dat", disabled, true);
		loader->UseFileSystem(Starshatter::UseFileSystem());

		ListIter<Text> iter = disabled;
		while (++iter) {
			Text* name = iter.value();
			name->setSensitive(false);

			if (*name == "shatter.dat"      || 
					*name == "beta.dat"         || 
					*name == "start.dat"        ||
					*name == "irunin.dat"       ||
					*name == "vox.dat"          ||
					name->contains("uninstall") ||
					enabled.contains(name))
			delete iter.removeItem();
		}
	}
}
开发者ID:lightgemini78,项目名称:Starshatter-Rearmed,代码行数:28,代码来源:ModConfig.cpp

示例11: while

void
TacticalAI::FindSupport()
{
    if (!ship_ai->GetThreat()) {
        ship_ai->SetSupport(0);
        return;
    }

    // pick the biggest friendly contact in the sector:
    Ship*       support        = 0;
    double      support_dist   = 1e9;

    ListIter<Contact> contact = ship->ContactList();

    while (++contact) {
        if (contact->GetShip() && contact->GetIFF(ship) == ship->GetIFF()) {
            Ship* c_ship = contact->GetShip();

            if (c_ship != ship && c_ship->Class() >= ship->Class() && !c_ship->InTransition()) {
                if (!support || c_ship->Class() > support->Class())
                support = c_ship;
            }
        }
    }

    ship_ai->SetSupport(support);
}
开发者ID:Banbury,项目名称:starshatter-open,代码行数:27,代码来源:TacticalAI.cpp

示例12: RandomIndex

void
CampaignPlanStrategic::PlaceGroup(CombatGroup* g)
{
    if (!g)
    return;

    Text        rgn  = g->GetRegion();
    CombatZone* zone = campaign->GetZone(rgn);

    // if we couldn't find anything suitable,
    // just pick a zone at random:
    if (!zone && g->IsMovable()) {
        int nzones = campaign->GetZones().size();
        int n      = RandomIndex() % nzones;
        zone       = campaign->GetZones().at(n);

        Text assigned_rgn;
        if (!campaign->GetZone(rgn)) {
            assigned_rgn = *zone->GetRegions().at(0);
            g->AssignRegion(assigned_rgn);
        }
    }

    if (zone && !zone->HasGroup(g))
    zone->AddGroup(g);

    ListIter<CombatGroup> iter = g->GetComponents();
    while (++iter)
    PlaceGroup(iter.value());
}
开发者ID:Banbury,项目名称:starshatter-open,代码行数:30,代码来源:CampaignPlanStrategic.cpp

示例13: if

void
Element::HandleRadioMessage(RadioMessage* msg)
{
	if (!msg) return;

	static RadioHandler rh;

	// if this is a message from within the element,
	// then all ships should report in.  Otherwise,
	// just the leader will acknowledge the message.
	int full_report = ships.contains(msg->Sender());
	int reported    = false;

	ListIter<Ship> s = ships;
	while (++s) {
		if (rh.ProcessMessage(msg, s.value())) {
			if (full_report) {
				if (s.value() != msg->Sender())
				rh.AcknowledgeMessage(msg, s.value());
			}

			else if (!reported) {
				rh.AcknowledgeMessage(msg, s.value());
				reported = true;
			}
		}
	}
}
开发者ID:The-E,项目名称:Starshatter-Experimental,代码行数:28,代码来源:Element.cpp

示例14: while

void
CampaignPlanStrategic::ScoreTarget(Combatant* c, CombatGroup* g)
{
    if (!g || g->IntelLevel() <= Intel::SECRET)
    return;

    if (g->IsTargetable()) {
        g->SetPlanValue(g->Value() * c->GetTargetStratFactor(g->Type()));
        c->GetTargetList().append(g);

        CombatZone* zone  = campaign->GetZone(g->GetRegion());
        ZoneForce*  force = 0;

        if (zone)
        force = zone->FindForce(c->GetIFF());

        if (force)
        force->GetTargetList().append(g);
    }

    ListIter<CombatGroup> iter = g->GetComponents();
    while (++iter) {
        ScoreTarget(c, iter.value());
    }
}
开发者ID:Banbury,项目名称:starshatter-open,代码行数:25,代码来源:CampaignPlanStrategic.cpp

示例15: Name

void
SimObject::Notify()
{
	if (!notifying) {
		notifying = true;

		int nobservers = observers.size();
		int nupdate    = 0;

		if (nobservers > 0) {
			ListIter<SimObserver> iter = observers;
			while (++iter) {
				SimObserver* observer = iter.value();
				observer->Update(this);
				nupdate++;
			}

			observers.clear();
		}

		if (nobservers != nupdate) {
			::Print("WARNING: incomplete notify sim object '%s' - %d of %d notified\n",
			Name(), nupdate, nobservers);
		}

		notifying = false;
	}
	else {
		::Print("WARNING: double notify on sim object '%s'\n", Name());
	}
}
开发者ID:lightgemini78,项目名称:Starshatter-Rearmed,代码行数:31,代码来源:SimObject.cpp


注:本文中的ListIter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。