Example #1
0
int PASCAL WinMain(HINSTANCE hInstance,
						 HINSTANCE hPrevInstance,
						 LPSTR lpCmdLine,
						 int nCmdShow)
{
	m_hInstance = hInstance;
#ifdef USE_WINDOW
	InitInstance(hInstance, hPrevInstance);
	CreateMyWindow();
#endif

	// Invoke the "Upgrade" function of the DLL.
	int nResult = (int)Upgrade(m_hWndMain, NULL, 2, 123456L);

	char result_buffer[80];
	sprintf(result_buffer, "Result (%d)", nResult);

	char buffer[80];
	sprintf(buffer, "Upgrade returned %s", result_buffer);
	MessageBox(m_hWndMain, buffer, "Upgrade", MB_OK);

#ifdef USE_WINDOW
	if (m_hWndMain != NULL)
	{
		DestroyWindow(m_hWndMain);
	}
#endif

	return 0;
}
void NFCSLGBuildingModule::OnSLGClienUpgradeBuilding(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen)
{
	CLIENT_MSG_PROCESS(nSockIndex, nMsgID, msg, nLen, NFMsg::ReqUpBuildLv);

	const NFGUID xBuilID = NFINetModule::PBToNF(xMsg.object_guid());
	Upgrade(nPlayerID, xBuilID);
}
//-----------------------------------------------------------------------------
// Button click handlers
//-----------------------------------------------------------------------------
void CResourcePumpControlPanel::OnCommand( const char *command )
{
	if (!V_strnicmp(command, "Upgrade", 7))
	{
		Upgrade();
		return;
	}

	BaseClass::OnCommand(command);
}
Example #4
0
/************************************************************************
*  初始化
************************************************************************/
bool Skill::init()
{
	if (!Entity::init())
	{
		return false;
	}
	SetDamageValue(10);
	m_pBloodProgress->setVisible(false);
	SetScope(256,256);
	m_nLevel = 0;
	m_fConsumeMagic = 0;
	Upgrade();
	return true;
}
Example #5
0
void UpgradeDir(const char* path, bool force, bool subdir, int& upgraded, int& ok, int& failed)
{
	WIN32_FIND_DATA find;
	printf("Upgrade checking dir '%s'\n", path);
	HANDLE f = FindFirstFile(Formats("%s/*", path), &find);
	if(f == INVALID_HANDLE_VALUE)
	{
		printf("FIND failed...\n");
		++failed;
		return;
	}

	do
	{
		if(find.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
		{
			if(subdir && strcmp(find.cFileName, ".") != 0 && strcmp(find.cFileName, "..") != 0)
			{
				string new_path = Formats("%s/%s", path, find.cFileName);
				UpgradeDir(new_path.c_str(), force, subdir, upgraded, ok, failed);
			}
		}
		else
		{
			if(EndsWith(find.cFileName, ".qmsh") || EndsWith(find.cFileName, ".phy"))
			{
				string file_path = Formats("%s/%s", path, find.cFileName);
				int result = Upgrade(file_path.c_str(), force);
				if(result == -1)
					failed++;
				else if(result == 0)
					ok++;
				else
					upgraded++;
			}
		}
	}
	while(FindNextFile(f, &find));

	FindClose(f);
}
Example #6
0
void CServerBrowser::Refresh(int Type, int NoReload)
{
	if(m_ServerdataLocked)
		return;
	if(NoReload || Type < 0)
	{
		if(NoReload == 1 && !IsRefreshing())
			m_NeedUpgrade = true;
		if(NoReload == 2 && m_NeedUpgrade)
			Upgrade();
		return;
	}

	// clear out everything
	m_ServerlistHeap.Reset();
	m_NumServers = 0;
	m_NumSortedServers = 0;
	mem_zero(m_aServerlistIp, sizeof(m_aServerlistIp));
	m_pFirstReqServer = 0;
	m_pLastReqServer = 0;
	m_NumRequests = 0;
	m_CurrentMaxRequests = g_Config.m_BrMaxRequests;
	// next token
	m_CurrentToken = (m_CurrentToken+1)&0xff;

	//
	m_ServerlistType = Type;
	m_NeedUpgrade = false;

	if(Type == IServerBrowser::TYPE_LAN)
	{
		unsigned char Buffer[sizeof(SERVERBROWSE_GETINFO)+1];
		CNetChunk Packet;
		int i;

		mem_copy(Buffer, SERVERBROWSE_GETINFO, sizeof(SERVERBROWSE_GETINFO));
		Buffer[sizeof(SERVERBROWSE_GETINFO)] = m_CurrentToken;

		/* do the broadcast version */
		Packet.m_ClientID = -1;
		mem_zero(&Packet, sizeof(Packet));
		Packet.m_Address.type = m_pNetClient->NetType()|NETTYPE_LINK_BROADCAST;
		Packet.m_Flags = NETSENDFLAG_CONNLESS;
		Packet.m_DataSize = sizeof(Buffer);
		Packet.m_pData = Buffer;
		m_BroadcastTime = time_get();

		for(i = 8303; i <= 8310; i++)
		{
			Packet.m_Address.port = i;
			m_pNetClient->Send(&Packet);
		}

		if(g_Config.m_Debug)
			m_pConsole->Print(IConsole::OUTPUT_LEVEL_DEBUG, "client_srvbrowse", "broadcasting for servers");
	}
	else if(Type == IServerBrowser::TYPE_INTERNET)
	{
		m_NeedRefresh = 1;
	}
	else if(Type == IServerBrowser::TYPE_FAVORITES)
	{
		for(int i = 0; i < m_NumFavoriteServers; i++)
			Set(m_aFavoriteServers[i], IServerBrowser::SET_FAV_ADD, -1, 0);
	}
	else if(Type == IServerBrowser::TYPE_RECENT)
	{
		for(int i = 0; i < m_aRecentServers.size(); i++)
			Set(m_aRecentServers[i].m_Addr, IServerBrowser::SET_RECENT, -1, 0);
	}
	else if(Type == IServerBrowser::TYPE_DDNET)
	{
		LoadDDNet();

		// remove unknown elements of exclude list
		DDNetCountryFilterClean();
		DDNetTypeFilterClean();

		for(int i = 0; i < m_NumDDNetCountries; i++)
		{
			CDDNetCountry *pCntr = &m_aDDNetCountries[i];

			// check for filter
			if(DDNetFiltered(g_Config.m_BrFilterExcludeCountries, pCntr->m_aName))
				continue;

			for(int g = 0; g < pCntr->m_NumServers; g++)
			{
				if(!DDNetFiltered(g_Config.m_BrFilterExcludeTypes, pCntr->m_aTypes[g]))
					Set(pCntr->m_aServers[g], IServerBrowser::SET_DDNET_ADD, -1, 0);
			}
		}
	}
}
Example #7
0
//=================================================================================================
// Pocz¹tek programu
//=================================================================================================
int main(int argc, char **argv)
{
	setlocale(LC_ALL, "");
	setlocale(LC_NUMERIC, "C");

	if(argc == 1)
	{
		printf("QMSH converter, version %s (output %d).\nUsage: \"converter FILE.qmsh.tmp\". Use \"converter -h\" for list of commands.\n",
			CONVERTER_VERSION, QMSH::VERSION);
		return 0;
	}
	export_phy = false;

	int result = 0;
	bool check_subdir = true, force_update = false;

	for(int i = 1; i < argc; ++i)
	{
		char* cstr = argv[i];

		if(cstr[0] == '-')
		{
			string str(cstr);

			if(str == "-h" || str == "-help" || str == "-?")
			{
				printf("Converter switches:\n"
					"-h/help/? - list of commands\n"
					"-v - show converter version and input file versions\n"
					"-o FILE - output file name\n"
					"-g1 - use single group (default)\n"
					"-gf FILE - use animation groups from file\n"
					"-gcreate - create animation groups and save as file\n"
					"-gcreaten FILE - create animation groups and save as named file\n"
					"-phy - export only physic mesh (default extension .phy)\n"
					"-normal - export normal mesh\n"
					"-info FILE - show information about mesh (version etc)\n"
					"-details OPTIONS FILE - like info but more details\n"
					"-compare FILE FILE2 - compare two meshes and show differences\n"
					"-upgrade FILE - upgrade mesh to newest version\n"
					"-upgradedir DIR - upgrade all meshes in directory and subdirectories\n"
					"-subdir - check subdirectories in upgradedir (default)\n"
					"-nosubdir - don't check subdirectories in upgradedir\n"
					"-force - force upgrade operation\n"
					"-noforce - don't force upgrade operation (default)\n"
					"Parameters without '-' are treated as input file.\n");
			}
			else if(str == "-v")
			{
				printf("Converter version %s\nHandled input file version: %d..%d\nOutput file version: %d\n",
					CONVERTER_VERSION, QmshTmpLoader::QMSH_TMP_HANDLED_VERSION.x, QmshTmpLoader::QMSH_TMP_HANDLED_VERSION.y, QMSH::VERSION);
			}
			else if(str == "-g1")
				gopt = GO_ONE;
			else if(str == "-gf")
			{
				if(i + 1 < argc)
				{
					++i;
					group_file = argv[i];
					gopt = GO_FILE;
				}
				else
					printf("Missing FILE name for '-gf'!\n");
			}
			else if(str == "-gcreate")
			{
				gopt = GO_CREATE;
				group_file.clear();
			}
			else if(str == "-gcreaten")
			{
				if(i + 1 < argc)
				{
					++i;
					group_file = argv[i];
					gopt = GO_CREATE;
				}
				else
					printf("Missing FILE name for '-gcreaten'!\n");
			}
			else if(str == "-o")
			{
				if(i + 1 < argc)
				{
					++i;
					output_file = argv[i];
					force_output = true;
				}
				else
					printf("Missing OUTPUT PATH for '-o'!\n");
			}
			else if(str == "-phy")
				export_phy = true;
			else if(str == "-normal")
				export_phy = false;
			else if(str == "-info")
			{
				if(i + 1 < argc)
				{
					++i;
					Info(argv[i]);
				}
				else
					printf("Missing FILE for '-info'!\n");
			}
			else if(str == "-details")
			{
				if(i + 2 < argc)
				{
					Info(argv[i + 2], argv[i + 1]);
					i += 2;
				}
				else
				{
					printf("Missing OPTIONS or FILE for '-details'!\n");
					++i;
				}
			}
			else if(str == "-compare")
			{
				if(i + 2 < argc)
				{
					Compare(argv[i + 1], argv[i + 2]);
					i += 2;
				}
				else
				{
					printf("Missing FILEs for '-compare'!\n");
					++i;
				}
			}
			else if(str == "-upgrade")
			{
				if(i + 1 < argc)
				{
					++i;
					Upgrade(argv[i], force_update);
				}
				else
					printf("Missing FILE for '-upgrade'!\n");
			}
			else if(str == "-upgradedir")
			{
				if(i + 1 < argc)
				{
					++i;
					UpgradeDir(argv[i], force_update, check_subdir);
				}
				else
					printf("Missing FILE for '-upgradedir'!\n");
			}
			else if(str == "-subdir")
				check_subdir = true;
			else if(str == "-nosubdir")
				check_subdir = false;
			else if(str == "-force")
				force_update = true;
			else if(str == "-noforce")
				force_update = false;
			else
				printf("Unknown switch \"%s\"!\n", cstr);
		}
		else
		{
			string tstr(cstr);
			if(!ConvertToQmsh(tstr))
				result = 1;
			group_file.clear();
			output_file.clear();
			gopt = GO_ONE;
		}
	}

	if(IsDebuggerPresent())
	{
		printf("Press any key to exit...");
		_getch();
	}

	return result;
}
/*--------------------------------------------------------------------------*/
int
main(int argc, char **argv)
{
  /*
  * Initalize hardware.
  */
  msp430_cpu_init();
  clock_init();

  uart_init(9600); /* Must come before first printf */

  /* xmem_init(); */

  PRINTF("iWatch 0.10 build at " __TIME__ " " __DATE__ "\n");
  UCSCTL8 &= ~BIT2;
  
  /*
  * Hardware initialization done!
  */

  /*
  * Initialize Contiki and our processes.
  */
  process_init();
  process_start(&etimer_process, NULL);
  
  rtimer_init();
  ctimer_init();

  energest_init();
  ENERGEST_ON(ENERGEST_TYPE_CPU);

  backlight_init();
  battery_init();
  SPI_FLASH_Init();

  if (system_testing())
  {
    clock_time_t t;

    backlight_on(200, 0);
    t = clock_seconds();
    // sleep 1
    while(clock_seconds() - t <= 3);
    printf("$$OK BACKLIGHT\n");
    t = clock_seconds();
    while(clock_seconds() - t <= 3);
    backlight_on(0, 0);

    motor_on(200, 0);
    // sleep 1s
    t = clock_seconds();
    while(clock_seconds() - t <= 3);
    printf("$$OK MOTOR\n");
    t = clock_seconds();
    while(clock_seconds() - t <= 3);
    motor_on(0, 0);

#if PRODUCT_W001
    I2C_Init();
    codec_init();
    codec_bypass(1);
    // sleep 1s
    t = clock_seconds();
    while(clock_seconds() - t <= 3);
    printf("$$OK MIC\n");
    // sleep 1s
    t = clock_seconds();
    while(clock_seconds() - t <= 3);
    codec_bypass(0);

    codec_shutdown();
#endif
  }

  int reason = CheckUpgrade();

  window_init(reason);

  button_init();
  rtc_init();
  CFSFontWrapperLoad();

  system_init(); // check system status and do factor reset if needed

  I2C_Init();

  //codec_init();
  //ant_init();
  bluetooth_init();

#ifdef PRODUCT_W004
  //bmx_init();
#else
  mpu6050_init();
#endif

  // check the button status
  if (button_snapshot() & (1 << BUTTON_UP))
  {
    clock_time_t t;
    // delay 1 second
    // button up is pressed, we will set emerging flag
    motor_on(200, CLOCK_SECOND * 2);
    t = clock_seconds();
    while(clock_seconds() - t <= 1);

    if (button_snapshot() & (1 << BUTTON_UP)) 

    system_setemerging();
    motor_on(0, 0);
  }  
  
  if (!system_retail())
  {
    bluetooth_discoverable(1);
  }

#if PRODUCT_W001
  if (system_testing())
    ant_init(MODE_HRM);
#endif
  
  system_restore();

//  protocol_init();
//  protocol_start(1);
  
  process_start(&system_process, NULL);

  /*
  * This is the scheduler loop.
  */
  msp430_dco_required = 0;

  /*
    check firmware update
    */
  if (reason == 0xff)
  {
    printf("Start Upgrade\n");
    Upgrade();
    // never return if sucessfully upgrade
  }

  watchdog_start();

  while(1) {
    int r;
    do {
      /* Reset watchdog. */
      watchdog_periodic();
      r = process_run();
    } while(r > 0);

    /*
    * Idle processing.
    */
    int s = splhigh();          /* Disable interrupts. */
    /* uart1_active is for avoiding LPM3 when still sending or receiving */
    if(process_nevents() != 0) {
      splx(s);                  /* Re-enable interrupts. */
    } else {
      static unsigned long irq_energest = 0;

      /* Re-enable interrupts and go to sleep atomically. */
      ENERGEST_OFF(ENERGEST_TYPE_CPU);
      ENERGEST_ON(ENERGEST_TYPE_LPM);
      /* We only want to measure the processing done in IRQs when we
         are asleep, so we discard the processing time done when we
         were awake. */
      energest_type_set(ENERGEST_TYPE_IRQ, irq_energest);
      watchdog_stop();

      if (shutdown_mode)
      {
        system_shutdown(1); // never return
        LPM4;
      }
      
      if (msp430_dco_required)
      {
        __low_power_mode_0();
      }
      else
      {
        __low_power_mode_3();
      }

      /* We get the current processing time for interrupts that was
         done during the LPM and store it for next time around.  */
      __disable_interrupt();
      irq_energest = energest_type_time(ENERGEST_TYPE_IRQ);
      __enable_interrupt();
      watchdog_start();
      ENERGEST_OFF(ENERGEST_TYPE_LPM);
      ENERGEST_ON(ENERGEST_TYPE_CPU);
    }
  }
}