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


C++ SlObject函数代码示例

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


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

示例1: Load_TOWN

void Load_TOWN()
{
	int index;

	while ((index = SlIterateArray()) != -1) {
		Town *t = new (index) Town();
		SlObject(t, _town_desc);
		t->LoadCargoSourceSink();

		if (IsSavegameVersionBefore(161)) continue;

		SlObject(&t->cargo_accepted, GetTileMatrixDesc());
		if (t->cargo_accepted.area.w != 0) {
			uint arr_len = t->cargo_accepted.area.w / AcceptanceMatrix::GRID * t->cargo_accepted.area.h / AcceptanceMatrix::GRID;
			t->cargo_accepted.data = MallocT<uint32>(arr_len);
			SlArray(t->cargo_accepted.data, arr_len, SLE_UINT32);

			/* Rebuild total cargo acceptance. */
			UpdateTownCargoTotal(t);
		}

		/* Cache the aligned tile index of the centre tile. */
		uint town_x = (TileX(t->xy) / AcceptanceMatrix::GRID) * AcceptanceMatrix::GRID;
		uint town_y = (TileY(t->xy) / AcceptanceMatrix::GRID) * AcceptanceMatrix::GRID;
		t->xy_aligned= TileXY(town_x, town_y);
	}
}
开发者ID:koreapyj,项目名称:openttd-yacd,代码行数:27,代码来源:town_sl.cpp

示例2: DoSave_LGRJ

/**
 * Save a link graph job.
 * @param lgj LinkGraphJob to be saved.
 */
static void DoSave_LGRJ(LinkGraphJob *lgj)
{
	SlObject(lgj, GetLinkGraphJobDesc());
	_num_nodes = lgj->Size();
	SlObject(const_cast<LinkGraph *>(&lgj->Graph()), GetLinkGraphDesc());
	SaveLoad_LinkGraph(const_cast<LinkGraph &>(lgj->Graph()));
}
开发者ID:IchiroWang,项目名称:OpenTTD,代码行数:11,代码来源:linkgraph_sl.cpp

示例3: Load_GLOG_common

static void Load_GLOG_common(LoggedAction *&gamelog_action, uint &gamelog_actions)
{
	assert(gamelog_action == NULL);
	assert(gamelog_actions == 0);

	GamelogActionType at;
	while ((at = (GamelogActionType)SlReadByte()) != GLAT_NONE) {
		gamelog_action = ReallocT(gamelog_action, gamelog_actions + 1);
		LoggedAction *la = &gamelog_action[gamelog_actions++];

		la->at = at;

		SlObject(la, _glog_action_desc); // has to be saved after 'DATE'!
		la->change = NULL;
		la->changes = 0;

		GamelogChangeType ct;
		while ((ct = (GamelogChangeType)SlReadByte()) != GLCT_NONE) {
			la->change = ReallocT(la->change, la->changes + 1);

			LoggedChange *lc = &la->change[la->changes++];
			/* for SLE_STR, pointer has to be valid! so make it NULL */
			memset(lc, 0, sizeof(*lc));
			lc->ct = ct;

			assert((uint)ct < GLCT_END);

			SlObject(lc, _glog_desc[ct]);
		}
	}
}
开发者ID:M3Henry,项目名称:openttd,代码行数:31,代码来源:gamelog_sl.cpp

示例4: Save_GLOG

static void Save_GLOG()
{
	const LoggedAction *laend = &_gamelog_action[_gamelog_actions];
	size_t length = 0;

	for (const LoggedAction *la = _gamelog_action; la != laend; la++) {
		const LoggedChange *lcend = &la->change[la->changes];
		for (LoggedChange *lc = la->change; lc != lcend; lc++) {
			assert((uint)lc->ct < lengthof(_glog_desc));
			length += SlCalcObjLength(lc, _glog_desc[lc->ct]) + 1;
		}
		length += 4;
	}
	length++;

	SlSetLength(length);

	for (LoggedAction *la = _gamelog_action; la != laend; la++) {
		SlWriteByte(la->at);
		SlObject(la, _glog_action_desc);

		const LoggedChange *lcend = &la->change[la->changes];
		for (LoggedChange *lc = la->change; lc != lcend; lc++) {
			SlWriteByte(lc->ct);
			assert((uint)lc->ct < GLCT_END);
			SlObject(lc, _glog_desc[lc->ct]);
		}
		SlWriteByte(GLCT_NONE);
	}
	SlWriteByte(GLAT_NONE);
}
开发者ID:M3Henry,项目名称:openttd,代码行数:31,代码来源:gamelog_sl.cpp

示例5: Load_STNN

static void Load_STNN()
{
	int index;

	while ((index = SlIterateArray()) != -1) {
		bool waypoint = (SlReadByte() & FACIL_WAYPOINT) != 0;

		BaseStation *bst = waypoint ? (BaseStation *)new (index) Waypoint() : new (index) Station();
		SlObject(bst, waypoint ? _waypoint_desc : _station_desc);

		if (!waypoint) {
			Station *st = Station::From(bst);
			for (CargoID i = 0; i < NUM_CARGO; i++) {
				SlObject(&st->goods[i], GetGoodsDesc());
			}
		}

		if (bst->num_specs != 0) {
			/* Allocate speclist memory when loading a game */
			bst->speclist = CallocT<StationSpecList>(bst->num_specs);
			for (uint i = 0; i < bst->num_specs; i++) {
				SlObject(&bst->speclist[i], _station_speclist_desc);
			}
		}
	}
}
开发者ID:Voxar,项目名称:OpenTTD,代码行数:26,代码来源:station_sl.cpp

示例6: Load_TOWN

static void Load_TOWN()
{
	int index;

	while ((index = SlIterateArray()) != -1) {
		Town *t = new (index) Town();
		SlObject(t, _town_desc);

		for (CargoID i = 0; i < NUM_CARGO; i++) {
			SlObject(&t->supplied[i], _town_supplied_desc);
		}
		for (int i = TE_BEGIN; i < TE_END; i++) {
			SlObject(&t->received[i], _town_received_desc);
		}

		if (t->townnamegrfid == 0 && !IsInsideMM(t->townnametype, SPECSTR_TOWNNAME_START, SPECSTR_TOWNNAME_LAST + 1) && GB(t->townnametype, 11, 5) != 15) {
			SlErrorCorrupt("Invalid town name generator");
		}

		if (IsSavegameVersionBefore(166)) continue;

		SlObject(&t->cargo_accepted, GetTileMatrixDesc());
		if (t->cargo_accepted.area.w != 0) {
			uint arr_len = t->cargo_accepted.area.w / AcceptanceMatrix::GRID * t->cargo_accepted.area.h / AcceptanceMatrix::GRID;
			t->cargo_accepted.data = MallocT<uint32>(arr_len);
			SlArray(t->cargo_accepted.data, arr_len, SLE_UINT32);

			/* Rebuild total cargo acceptance. */
			UpdateTownCargoTotal(t);
		}
	}
}
开发者ID:Johnnei,项目名称:OpenTTD,代码行数:32,代码来源:town_sl.cpp

示例7: SlObject

/* static */ bool ScriptInstance::LoadObjects(HSQUIRRELVM vm)
{
	SlObject(NULL, _script_byte);
	switch (_script_sl_byte) {
		case SQSL_INT: {
			int value;
			SlArray(&value, 1, SLE_INT32);
			if (vm != NULL) sq_pushinteger(vm, (SQInteger)value);
			return true;
		}

		case SQSL_STRING: {
			SlObject(NULL, _script_byte);
			static char buf[256];
			SlArray(buf, _script_sl_byte, SLE_CHAR);
			if (vm != NULL) sq_pushstring(vm, OTTD2SQ(buf), -1);
			return true;
		}

		case SQSL_ARRAY: {
			if (vm != NULL) sq_newarray(vm, 0);
			while (LoadObjects(vm)) {
				if (vm != NULL) sq_arrayappend(vm, -2);
				/* The value is popped from the stack by squirrel. */
			}
			return true;
		}

		case SQSL_TABLE: {
			if (vm != NULL) sq_newtable(vm);
			while (LoadObjects(vm)) {
				LoadObjects(vm);
				if (vm != NULL) sq_rawset(vm, -3);
				/* The key (-2) and value (-1) are popped from the stack by squirrel. */
			}
			return true;
		}

		case SQSL_BOOL: {
			SlObject(NULL, _script_byte);
			if (vm != NULL) sq_pushinteger(vm, (SQBool)(_script_sl_byte != 0));
			return true;
		}

		case SQSL_NULL: {
			if (vm != NULL) sq_pushnull(vm);
			return true;
		}

		case SQSL_ARRAY_TABLE_END: {
			return false;
		}

		default: NOT_REACHED();
	}
}
开发者ID:Ayutac,项目名称:OpenTTD,代码行数:56,代码来源:script_instance.cpp

示例8: RealSave_TOWN

void RealSave_TOWN(Town *t)
{
	SlObject(t, _town_desc);
	t->SaveCargoSourceSink();

	if (IsSavegameVersionBefore(161)) return;

	SlObject(&t->cargo_accepted, GetTileMatrixDesc());
	if (t->cargo_accepted.area.w != 0) {
		uint arr_len = t->cargo_accepted.area.w / AcceptanceMatrix::GRID * t->cargo_accepted.area.h / AcceptanceMatrix::GRID;
		SlArray(t->cargo_accepted.data, arr_len, SLE_UINT32);
	}
}
开发者ID:koreapyj,项目名称:openttd-yacd,代码行数:13,代码来源:town_sl.cpp

示例9: Load_AIPL

static void Load_AIPL()
{
	CompanyID index;
	while ((index = (CompanyID)SlIterateArray()) != (CompanyID)-1) {
		SlObject(NULL, _ai_company);

		if (!Company::IsValidAiID(index)) continue;
		SlObject(NULL, _ai_byte);
		/* Check if there was anything saved at all. */
		if (_ai_sl_byte == 0) continue;
		LoadObjects();
	}
}
开发者ID:dolly22,项目名称:openttd-sai,代码行数:13,代码来源:ai_sl.cpp

示例10: Ptrs_CAPY

static void Ptrs_CAPY()
{
	CargoPayment *cp;
	FOR_ALL_CARGO_PAYMENTS(cp) {
		SlObject(cp, _cargopayment_desc);
	}
}
开发者ID:koreapyj,项目名称:openttd-yapp,代码行数:7,代码来源:economy_sl.cpp

示例11: Ptrs_STNS

static void Ptrs_STNS()
{
	/* Don't run when savegame version is higher than or equal to 123. */
	if (!CheckSavegameVersion(123)) return;

	Station *st;
	FOR_ALL_STATIONS(st) {
		if (!CheckSavegameVersion(68)) {
			for (CargoID i = 0; i < NUM_CARGO; i++) {
				GoodsEntry *ge = &st->goods[i];
				SlObject(ge, GetGoodsDesc());
			}
		}
		SlObject(st, _old_station_desc);
	}
}
开发者ID:Voxar,项目名称:OpenTTD,代码行数:16,代码来源:station_sl.cpp

示例12: Load_LGRJ

/**
 * Load all link graph jobs.
 */
static void Load_LGRJ()
{
	int index;
	while ((index = SlIterateArray()) != -1) {
		if (!LinkGraphJob::CanAllocateItem()) {
			/* Impossible as they have been present in previous game. */
			NOT_REACHED();
		}
		LinkGraphJob *lgj = new (index) LinkGraphJob();
		SlObject(lgj, GetLinkGraphJobDesc());
		LinkGraph &lg = const_cast<LinkGraph &>(lgj->Graph());
		SlObject(&lg, GetLinkGraphDesc());
		lg.Init(_num_nodes);
		SaveLoad_LinkGraph(lg);
	}
}
开发者ID:IchiroWang,项目名称:OpenTTD,代码行数:19,代码来源:linkgraph_sl.cpp

示例13: Ptrs_ROADSTOP

static void Ptrs_ROADSTOP()
{
	RoadStop *rs;
	FOR_ALL_ROADSTOPS(rs) {
		SlObject(rs, _roadstop_desc);
	}
}
开发者ID:Voxar,项目名称:OpenTTD,代码行数:7,代码来源:station_sl.cpp

示例14: RealSave_STNN

static void RealSave_STNN(BaseStation *bst)
{
	bool waypoint = (bst->facilities & FACIL_WAYPOINT) != 0;
	SlObject(bst, waypoint ? _waypoint_desc : _station_desc);

	if (!waypoint) {
		Station *st = Station::From(bst);
		for (CargoID i = 0; i < NUM_CARGO; i++) {
			SlObject(&st->goods[i], GetGoodsDesc());
		}
	}

	for (uint i = 0; i < bst->num_specs; i++) {
		SlObject(&bst->speclist[i], _station_speclist_desc);
	}
}
开发者ID:Voxar,项目名称:OpenTTD,代码行数:16,代码来源:station_sl.cpp

示例15: Save_NewGRFMapping

/**
 * Save a GRF ID + local id -> OpenTTD's id mapping.
 * @param mapping The mapping to save.
 */
void Save_NewGRFMapping(const OverrideManagerBase &mapping)
{
	for (uint i = 0; i < mapping.GetMaxMapping(); i++) {
		SlSetArrayIndex(i);
		SlObject(&mapping.mapping_ID[i], _newgrf_mapping_desc);
	}
}
开发者ID:Junky2008,项目名称:OpenTTD,代码行数:11,代码来源:newgrf_sl.cpp


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