示例#1
0
文件: cmd.cpp 项目: voidpaper/sgs2010
static RESULT cmd_useskill(const char** argv, int argc, GameContext* pContext, GameEventContext* pEvent)
{
	int    idx;
	RESULT ret;
	if(get_game_status(pContext) == Status_None)
	{
		MSG_OUT("当前不在游戏中!\n");
		return R_E_STATUS;
	}

	ret = R_DEF;

	if(argc >= 2 && 0 == to_int(argv[1], &idx))
	{
		ret = game_cmd_use_skill(pContext, pEvent, idx);
	}
	else if(argc >= 2 && (0 == strcasecmp(argv[1], "weapon") || 0 == strcasecmp(argv[1], "w")) )
	{
		ret = game_cmd_use_weapon(pContext, pEvent);
	}
	else if(argc >= 2 && (0 == strcasecmp(argv[1], "armor") || 0 == strcasecmp(argv[1], "a")) )
	{
		ret = game_cmd_use_armor(pContext, pEvent);
	}
	else
	{
		param_error(argv[0]);
		return R_E_PARAM;
	}
	
	return ret;
}
示例#2
0
文件: cmd.cpp 项目: voidpaper/sgs2010
static RESULT cmd_discard(const char** argv, int argc, GameContext* pContext, GameEventContext* pEvent)
{
	int idx[MAX_PARAM_NUM];
	int cnt = 0;
	int n;

	if(get_game_status(pContext) == Status_None)
	{
		MSG_OUT("当前不在游戏中!\n");
		return R_E_STATUS;
	}

	if(argc < 2)
	{
		param_error(argv[0]);
		return R_E_PARAM;
	}

	
	for(n = 1; n < argc && cnt < MAX_PARAM_NUM; n++)
	{
		if(0 != to_int(argv[n], &idx[cnt]))
		{
			param_error(argv[0]);
			return R_E_PARAM;
		}
		cnt++;
	}


	return game_cmd_discard_card(pContext, pEvent, idx, cnt);
}
示例#3
0
文件: force.c 项目: Comanche93/eech
void add_to_force_info (entity *force_en, entity *new_en)
{

	force
		*raw;

	int
		index;

	if (!force_en)
	{

		return;
	}

	if (!get_force_hardware_update ())
	{

		return;
	}
		
	raw = (force *) get_local_entity_data (force_en);

	index = get_local_entity_int_value (new_en, INT_TYPE_FORCE_INFO_CATAGORY);

	raw->force_info_current_hardware [index] ++;

	if (get_game_status () == GAME_STATUS_INITIALISED)
	{

		raw->force_info_reserve_hardware [index] --;
	}
}
示例#4
0
文件: cmd.cpp 项目: voidpaper/sgs2010
static RESULT cmd_pass(const char** argv, int argc, GameContext* pContext, GameEventContext* pEvent)
{
	if(get_game_status(pContext) == Status_None)
	{
		MSG_OUT("当前不在游戏中!\n");
		return R_E_STATUS;
	}


	return game_cmd_pass(pContext, pEvent);

	//return CMD_RET_SUCC;
}
示例#5
0
文件: cmd.cpp 项目: voidpaper/sgs2010
static RESULT cmd_get(const char** argv, int argc, GameContext* pContext, GameEventContext* pEvent)
{
	if(get_game_status(pContext) == Status_None)
	{
		MSG_OUT("当前不在游戏中!\n");
		return R_E_STATUS;
	}
	int num = 1;
	if(argc>= 2)
	{
		if(0 != to_int(argv[1], &num))
		{
			num = 1;
		}
	}

	return game_cmd_getcard(pContext, pEvent, num);
}
示例#6
0
文件: cmd.cpp 项目: voidpaper/sgs2010
static RESULT cmd_save(const char** argv, int argc, GameContext* pContext, GameEventContext* pEvent)
{
	if(get_game_status(pContext) == Status_None)
	{
		MSG_OUT("当前不在游戏中,不能保存进度!\n");
		return R_E_STATUS;
	}

	if(argc != 2)
	{
		param_error(argv[0]);
		return R_E_PARAM;
	}


	game_save(pContext, argv[1]);

	return R_DEF;
}
示例#7
0
文件: cmd.cpp 项目: voidpaper/sgs2010
RESULT cmd_loop(GameContext* pContext, GameEventContext* pEvent, YESNO force, const char* strAlter)
{
	char  prompt[MAX_NAME_LEN + 10];
	char  cmdline[MAX_CMD_LEN];
	const char*  argv[MAX_PARAM_NUM];
	int   argc;
	char  *next, *w;
	int   n;
	RESULT   ret;

	if(get_game_status(pContext) == Status_None)
	{
		snprintf(prompt, sizeof(prompt), "[SGS2010] $ ");
	}
	else
	{
		snprintf(prompt, sizeof(prompt), "[%s] $ ", CUR_PLAYER(pContext)->name);
	}

	while(1)
	{
		if (strAlter != NULL) 
		{
			MSG_OUT("%s\n", strAlter) ;
		}

		if(NULL == get_cmd_line(pContext, pEvent, prompt, cmdline, sizeof(cmdline)))
		{
			break;
		}

		next =  cmdline;
		argc = 0;
		memset(argv, 0, sizeof(argv));
		while( NULL != (w = get_word(next, &next) ) )
		{
			if(argc < (int)COUNT(argv))
			{
				argv[argc++] = w;
			}
		}

		if(*next != 0)
		{
			MSG_OUT("error cmd at col %d!\n", (int)(next - cmdline));
		}
		else if(argc > 0)
		{
			ret = R_DEF;

			//if(funper != NULL)
			//{
			//	ret = (*funper)(argv, argc, pContext, ud);
			//	if(ret < 0)
			//		return ret;
			//}

			if(ret == R_DEF)
			{
				for(n= 0; n < CMD_NUM; n++)
				{
					if(!strcmp(argv[0], s_cmdDispatch[n].name) || (s_cmdDispatch[n].sort_name && !strcmp(argv[0], s_cmdDispatch[n].sort_name)))
					{
						break;
					}
				}

				if(n < CMD_NUM)
				{

					ret = (*s_cmdDispatch[n].func)(argv, argc, pContext, pEvent);

					if(ret == R_CANCEL && force == YES)
					{
						MSG_OUT("当前不能取消(放弃)操作!\n");
					}
					else
					{
						switch(ret)
						{
						case R_SUCC:         // success and back to caller
						case R_BACK:         // back to caller no result
						case R_CANCEL:       // cancel current operator and back to caller
						case R_EXIT:         // exit game 
							return ret;
						default:
							break;
						}
					}
				}
				else
				{
					MSG_OUT("无效的命令:\'%s\'!\n", argv[0]);
				}
			}
		}
	}

	//  end of input ???
	return R_EXIT;
}
示例#8
0
static void set_local_int_value (entity *en, int_types type, int value)
{
	sector
		*raw;

	#if DEBUG_MODULE

	debug_log_entity_args (ENTITY_DEBUG_LOCAL, ENTITY_DEBUG_INT_VALUE, en, type, value);

	#endif

	raw = get_local_entity_data (en);

	switch (type)
	{
		////////////////////////////////////////
		case INT_TYPE_KEYSITE_COUNT:
		////////////////////////////////////////
		{
			raw->keysite_count = value;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_SIDE:
		////////////////////////////////////////
		{
			raw->side = value;

			#ifdef DEBUG

			if (value != ENTITY_SIDE_NEUTRAL)
			{
				ASSERT (get_game_status () == GAME_STATUS_INITIALISING);
			}

			#endif
			
			break;
		}
		////////////////////////////////////////
		case INT_TYPE_X_SECTOR:
		////////////////////////////////////////
		{
			raw->x_sector = value;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_Z_SECTOR:
		////////////////////////////////////////
		{
			raw->z_sector = value;

			break;
		}
		////////////////////////////////////////
		default:
		////////////////////////////////////////
		{
			debug_fatal_invalid_int_type (en, type);

			break;
		}
	}
}
示例#9
0
static void destroy_local (entity *en)
{

	fixed_wing
		*raw;

	////////////////////////////////////////
	//
	// PRE-AMBLE
	//
	////////////////////////////////////////

	#if DEBUG_MODULE >= 2

	debug_log_entity_args (ENTITY_DEBUG_LOCAL, ENTITY_DEBUG_DESTROY, en);

	#endif

	raw = (fixed_wing *) get_local_entity_data (en);

	if (get_game_status () == GAME_STATUS_INITIALISED)
	{
		ASSERT (!get_local_entity_int_value (en, INT_TYPE_ALIVE));
	}
	else
	{
		set_local_entity_int_value (en, INT_TYPE_ALIVE, FALSE);
	}

	////////////////////////////////////////
	//
	// VALIDATE
	//
	////////////////////////////////////////

	////////////////////////////////////////
	//
	// DESTROY COMPONENTS
	//
	////////////////////////////////////////

	destruct_3d_object (raw->ac.inst3d);

	free_mem (raw->ac.weapon_package_status_array);

	if (raw->ac.sound_effect_data)
	{

		destroy_system_sound_effect (raw->ac.sound_effect_data);
	}

	////////////////////////////////////////
	//
	// UNLINK FROM SYSTEM
	//
	////////////////////////////////////////

	//
	// fixed_wing
	//

	//
	// aircraft
	//

	// aircrew_root

	unlink_local_entity_children (en, LIST_TYPE_TASK_DEPENDENT);

	unlink_local_entity_children (en, LIST_TYPE_LAUNCHED_WEAPON);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_FOLLOWER);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_DESIGNATED_TARGET); // Jabberwock 031107 Designated targets

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_GUNSHIP_TARGET);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_MEMBER);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_VIEW);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_TAKEOFF_QUEUE);

	//
	// mobile
	//

	unlink_local_entity_children (en, LIST_TYPE_SPECIAL_EFFECT);

	unlink_local_entity_children (en, LIST_TYPE_TARGET);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_PADLOCK);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_SECTOR);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_TARGET);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_UPDATE);

	#if LANDING_ROUTE_CHECK

	destroy_debug_entity_landing_route_check (en);

	#endif

	////////////////////////////////////////
	//
	// FREE ENTITY DATA
	//
	////////////////////////////////////////

	free_mem (raw);

	set_free_entity (en);
}