예제 #1
0
int APIENTRY WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    int argc = __argc;
    char **argv = __argv;
#else
int main(int argc, char *argv[])
{
#endif
    int seed = time(NULL);
    bool verifyexit = false;
    bool check_mods = false;
    std::string dump;
    dump_mode dmode = dump_mode::TSV;
    std::vector<std::string> opts;
    std::string world; /** if set try to load first save in this world on startup */

    // Set default file paths
#ifdef PREFIX
#define Q(STR) #STR
#define QUOTE(STR) Q(STR)
    PATH_INFO::init_base_path(std::string(QUOTE(PREFIX)));
#else
    PATH_INFO::init_base_path("");
#endif

#if (defined USE_HOME_DIR || defined USE_XDG_DIR)
    PATH_INFO::init_user_dir();
#else
    PATH_INFO::init_user_dir("./");
#endif
    PATH_INFO::set_standard_filenames();

    MAP_SHARING::setDefaults();
    {
        const char *section_default = nullptr;
        const char *section_map_sharing = "Map sharing";
        const char *section_user_directory = "User directories";
        const std::array<arg_handler, 12> first_pass_arguments = {{
            {
                "--seed", "<string of letters and or numbers>",
                "Sets the random number generator's seed value",
                section_default,
                [&seed](int num_args, const char **params) -> int {
                    if (num_args < 1) return -1;
                    const unsigned char *hash_input = (const unsigned char *) params[0];
                    seed = djb2_hash(hash_input);
                    return 1;
                }
            },
            {
                "--jsonverify", nullptr,
                "Checks the cdda json files",
                section_default,
                [&verifyexit](int, const char **) -> int {
                    verifyexit = true;
                    return 0;
                }
            },
            {
                "--check-mods", "[mods...]",
                "Checks the json files belonging to cdda mods",
                section_default,
                [&check_mods,&opts]( int n, const char *params[] ) -> int {
                    check_mods = true;
                    test_mode = true;
                    for( int i = 0; i < n; ++i ) {
                        opts.emplace_back( params[ i ] );
                    }
                    return 0;
                }
            },
            {
                "--dump-stats", "<what> [mode = TSV] [opts...]",
                "Dumps item stats",
                section_default,
                [&dump,&dmode,&opts](int n, const char *params[]) -> int {
                    if( n < 1 ) {
                        return -1;
                    }
                    test_mode = true;
                    dump = params[ 0 ];
                    for( int i = 2; i < n; ++i ) {
                        opts.emplace_back( params[ i ] );
                    }
                    if( n >= 2 ) {
                        if( !strcmp( params[ 1 ], "TSV" ) ) {
                            dmode = dump_mode::TSV;
                            return 0;
                        } else if( !strcmp( params[ 1 ], "HTML" ) ) {
                            dmode = dump_mode::HTML;
                            return 0;
                        } else {
                            return -1;
                        }
                    }
                    return 0;
                }
            },
            {
                "--world", "<name>",
                "Load world",
                section_default,
                [&world](int n, const char *params[]) -> int {
                    if( n < 1 ) {
                        return -1;
                    }
                    world = params[0];
                    return 1;
                }
            },
            {
                "--basepath", "<path>",
                "Base path for all game data subdirectories",
                section_default,
                [](int num_args, const char **params) {
                    if (num_args < 1) return -1;
                    PATH_INFO::init_base_path(params[0]);
                    PATH_INFO::set_standard_filenames();
                    return 1;
                }
            },
            {
                "--shared", nullptr,
                "Activates the map-sharing mode",
                section_map_sharing,
                [](int, const char **) -> int {
                    MAP_SHARING::setSharing(true);
                    MAP_SHARING::setCompetitive(true);
                    MAP_SHARING::setWorldmenu(false);
                    return 0;
                }
            },
            {
                "--username", "<name>",
                "Instructs map-sharing code to use this name for your character.",
                section_map_sharing,
                [](int num_args, const char **params) -> int {
                    if (num_args < 1) return -1;
                    MAP_SHARING::setUsername(params[0]);
                    return 1;
                }
            },
            {
                "--addadmin", "<username>",
                "Instructs map-sharing code to use this name for your character and give you "
                    "access to the cheat functions.",
                section_map_sharing,
                [](int num_args, const char **params) -> int {
                    if (num_args < 1) return -1;
                    MAP_SHARING::addAdmin(params[0]);
                    return 1;
                }
            },
            {
                "--adddebugger", "<username>",
                "Informs map-sharing code that you're running inside a debugger",
                section_map_sharing,
                [](int num_args, const char **params) -> int {
                    if (num_args < 1) return -1;
                    MAP_SHARING::addDebugger(params[0]);
                    return 1;
                }
            },
            {
                "--competitive", nullptr,
                "Instructs map-sharing code to disable access to the in-game cheat functions",
                section_map_sharing,
                [](int, const char **) -> int {
                    MAP_SHARING::setCompetitive(true);
                    return 0;
                }
            },
            {
                "--userdir", "<path>",
                "Base path for user-overrides to files from the ./data directory and named below",
                section_user_directory,
                [](int num_args, const char **params) -> int {
                    if (num_args < 1) return -1;
                    PATH_INFO::init_user_dir(params[0]);
                    PATH_INFO::set_standard_filenames();
                    return 1;
                }
            }
        }};

        // The following arguments are dependent on one or more of the previous flags and are run
        // in a second pass.
        const std::array<arg_handler, 9> second_pass_arguments = {{
            {
                "--worldmenu", nullptr,
                "Enables the world menu in the map-sharing code",
                section_map_sharing,
                [](int, const char **) -> int {
                    MAP_SHARING::setWorldmenu(true);
                    return true;
                }
            },
            {
                "--datadir", "<directory name>",
                "Sub directory from which game data is loaded",
                nullptr,
                [](int num_args, const char **params) -> int {
                      if (num_args < 1) return -1;
                      PATH_INFO::update_pathname("datadir", params[0]);
                      PATH_INFO::update_datadir();
                      return 1;
                }
            },
            {
                "--savedir", "<directory name>",
                "Subdirectory for game saves",
                section_user_directory,
                [](int num_args, const char **params) -> int {
                    if (num_args < 1) return -1;
                    PATH_INFO::update_pathname("savedir", params[0]);
                    return 1;
                }
            },
            {
                "--configdir", "<directory name>",
                "Subdirectory for game configuration",
                section_user_directory,
                [](int num_args, const char **params) -> int {
                    if (num_args < 1) return -1;
                    PATH_INFO::update_pathname("config_dir", params[0]);
                    PATH_INFO::update_config_dir();
                    return 1;
                }
            },
            {
                "--memorialdir", "<directory name>",
                "Subdirectory for memorials",
                section_user_directory,
                [](int num_args, const char **params) -> int {
                    if (num_args < 1) return -1;
                    PATH_INFO::update_pathname("memorialdir", params[0]);
                    return 1;
                }
            },
            {
                "--optionfile", "<filename>",
                "Name of the options file within the configdir",
                section_user_directory,
                [](int num_args, const char **params) -> int {
                    if (num_args < 1) return -1;
                    PATH_INFO::update_pathname("options", params[0]);
                    return 1;
                }
            },
            {
                "--keymapfile", "<filename>",
                "Name of the keymap file within the configdir",
                section_user_directory,
                [](int num_args, const char **params) -> int {
                    if (num_args < 1) return -1;
                    PATH_INFO::update_pathname("keymap", params[0]);
                    return 1;
                }
            },
            {
                "--autopickupfile", "<filename>",
                "Name of the autopickup options file within the configdir",
                nullptr,
                [](int num_args, const char **params) -> int {
                    if (num_args < 1) return -1;
                    PATH_INFO::update_pathname("autopickup", params[0]);
                    return 1;
                }
            },
            {
                "--motdfile", "<filename>",
                "Name of the message of the day file within the motd directory",
                nullptr,
                [](int num_args, const char **params) -> int {
                    if (num_args < 1) return -1;
                    PATH_INFO::update_pathname("motd", params[0]);
                    return 1;
                }
            },
        }};

        // Process CLI arguments.
        const size_t num_first_pass_arguments =
            sizeof(first_pass_arguments) / sizeof(first_pass_arguments[0]);
        const size_t num_second_pass_arguments =
            sizeof(second_pass_arguments) / sizeof(second_pass_arguments[0]);
        int saved_argc = --argc; // skip program name
        const char **saved_argv = (const char **)++argv;
        while (argc) {
            if(!strcmp(argv[0], "--help")) {
                printHelpMessage(first_pass_arguments.data(), num_first_pass_arguments,
                    second_pass_arguments.data(), num_second_pass_arguments);
                return 0;
            } else {
                bool arg_handled = false;
                for (size_t i = 0; i < num_first_pass_arguments; ++i) {
                    auto &arg_handler = first_pass_arguments[i];
                    if (!strcmp(argv[0], arg_handler.flag)) {
                        argc--;
                        argv++;
                        int args_consumed = arg_handler.handler(argc, (const char **)argv);
                        if (args_consumed < 0) {
                            printf("Failed parsing parameter '%s'\n", *(argv - 1));
                            exit(1);
                        }
                        argc -= args_consumed;
                        argv += args_consumed;
                        arg_handled = true;
                        break;
                    }
                }
                // Skip other options.
                if (!arg_handled) {
                    --argc;
                    ++argv;
                }
            }
        }
        while (saved_argc) {
            bool arg_handled = false;
            for (size_t i = 0; i < num_second_pass_arguments; ++i) {
                auto &arg_handler = second_pass_arguments[i];
                if (!strcmp(saved_argv[0], arg_handler.flag)) {
                    --saved_argc;
                    ++saved_argv;
                    int args_consumed = arg_handler.handler(saved_argc, saved_argv);
                    if (args_consumed < 0) {
                        printf("Failed parsing parameter '%s'\n", *(argv - 1));
                        exit(1);
                    }
                    saved_argc -= args_consumed;
                    saved_argv += args_consumed;
                    arg_handled = true;
                    break;
                }
            }
            // Ingore unknown options.
            if (!arg_handled) {
                --saved_argc;
                ++saved_argv;
            }
        }
    }

    if (!assure_dir_exist(FILENAMES["user_dir"].c_str())) {
        printf("Can't open or create %s. Check permissions.\n",
               FILENAMES["user_dir"].c_str());
        exit(1);
    }

    setupDebug();

/**
 * OS X does not populate locale env vars correctly (they usually default to
 * "C") so don't bother trying to set the locale based on them.
 */
#if (!defined MACOSX)
    if (setlocale(LC_ALL, "") == NULL) {
        DebugLog(D_WARNING, D_MAIN) << "Error while setlocale(LC_ALL, '').";
    } else {
#endif
        try {
            std::locale::global( std::locale( "" ) );
        } catch( const std::exception& ) {
            // if user default locale retrieval isn't implemented by system
            try{
                // default to basic C locale
                std::locale::global( std::locale::classic() );
            } catch( const std::exception &err ) {
                debugmsg( "%s", err.what() );
                exit_handler(-999);
            }
        }
#if (!defined MACOSX)
    }
#endif

    get_options().init();
    get_options().load();
    set_language();

    // in test mode don't initialize curses to avoid escape sequences being inserted into output stream
    if( !test_mode ) {
        try {
			catacurses::init_interface();
        } catch( const std::exception &err ) {
            // can't use any curses function as it has not been initialized
            std::cerr << "Error while initializing the interface: " << err.what() << std::endl;
            DebugLog( D_ERROR, DC_ALL ) << "Error while initializing the interface: " << err.what() << "\n";
            return 1;
        }
    }

    srand(seed);

    g = new game;
    // First load and initialize everything that does not
    // depend on the mods.
    try {
        g->load_static_data();
        if (verifyexit) {
            exit_handler(0);
        }
        if( !dump.empty() ) {
            init_colors();
            exit( g->dump_stats( dump, dmode, opts ) ? 0 : 1 );
        }
        if( check_mods ) {
            init_colors();
            loading_ui ui( false );
            exit( g->check_mod_data( opts, ui ) && !test_dirty ? 0 : 1 );
        }
    } catch( const std::exception &err ) {
        debugmsg( "%s", err.what() );
        exit_handler(-999);
    }

    // Now we do the actual game.

    g->init_ui();

    curs_set(0); // Invisible cursor here, because MAPBUFFER.load() is crash-prone

#if (!(defined _WIN32 || defined WINDOWS))
    struct sigaction sigIntHandler;
    sigIntHandler.sa_handler = exit_handler;
    sigemptyset(&sigIntHandler.sa_mask);
    sigIntHandler.sa_flags = 0;
    sigaction(SIGINT, &sigIntHandler, NULL);
#endif

#ifdef LOCALIZE
    std::string lang = "";
#if (defined _WIN32 || defined WINDOWS)
    lang = getLangFromLCID( GetUserDefaultLCID() );
#else
    const char *v = setlocale( LC_ALL, NULL );
    if( v != NULL ) {
        lang = v;

        if( lang == "C" ) {
            lang = "en";
        }
    }
#endif
    if( get_option<std::string>( "USE_LANG" ).empty() && ( lang.empty() || !isValidLanguage( lang ) ) ) {
        select_language();
        set_language();
    }
#endif

    while( true ) {
        if( !world.empty() ) {
            if( !g->load( world ) ) {
                break;
            }
            world.clear(); // ensure quit returns to opening screen

        } else {
            main_menu menu;
            if( !menu.opening_screen() ) {
                break;
            }
        }

        while( !g->do_turn() );
    };


    exit_handler(-999);
    return 0;
}
예제 #2
0
void TokensTree::eraseToken(Token* oldToken)
{
    if(!oldToken)
        return;
    int idx = oldToken->m_Self;
    if(m_Tokens[idx]!=oldToken)
        return;

    // Step 1: Detach token from its parent

    Token* parentToken = 0;
    if((size_t)(oldToken->m_ParentIndex) >= m_Tokens.size())
        oldToken->m_ParentIndex = -1;
    if(oldToken->m_ParentIndex >= 0)
        parentToken = m_Tokens[oldToken->m_ParentIndex];
    if(parentToken)
        parentToken->m_Children.erase(idx);

    TokenIdxSet nodes;
    TokenIdxSet::iterator it;

    // Step 2: Detach token from its ancestors

    nodes = (oldToken->m_DirectAncestors);
    for(it = nodes.begin();it!=nodes.end(); it++)
    {
        int ancestoridx = *it;
        if(ancestoridx < 0 || (size_t)ancestoridx >= m_Tokens.size())
            continue;
        Token* ancestor = m_Tokens[ancestoridx];
        if(ancestor)
            ancestor->m_Descendants.erase(idx);
    }
    oldToken->m_Ancestors.clear();
    oldToken->m_DirectAncestors.clear();

    // Step 3: erase children

    nodes = (oldToken->m_Children); // Copy the list to avoid interference
    for(it = nodes.begin();it!=nodes.end(); it++)
        eraseToken(*it);
    // m_Children SHOULD be empty by now - but clear anyway.
    oldToken->m_Children.clear();

    // Step 4: erase descendants

    nodes = oldToken->m_Descendants; // Copy the list to avoid interference
    for(it = nodes.begin();it!=nodes.end(); it++)
    {
        if(*it == idx) // that should not happen, we can not be our own descendant, but in fact that can happen with boost
        {
            DebugLog(cc_text("Break out the loop to erase descendants, to avoid a crash. We can not be our own descendant !!"));
            break;
        }
         eraseToken(*it);
    }
    // m_Descendants SHOULD be empty by now - but clear anyway.
    oldToken->m_Descendants.clear();

    // Step 5: Detach token from the SearchTrees

    int idx2 = m_Tree.GetItemIdx(oldToken->m_Name);
    if(idx2)
    {
        TokenIdxSet& curlist = m_Tree.GetItemAtPos(idx2);
        curlist.erase(idx);
    }

    // Now, from the global namespace (if applicable)
    if(oldToken->m_ParentIndex == -1)
    {
        m_GlobalNameSpace.erase(idx);
        m_TopNameSpaces.erase(idx);
    }

    // Step 6: Finally, erase it from the list.

    eraseTokenFromList(idx);
}
예제 #3
0
string SDLInit(const char *title, int2 &screensize, bool fullscreen)
{
    //SDL_SetMainReady();
    if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER /* | SDL_INIT_AUDIO*/) < 0)
    {
        return SDLError("Unable to initialize SDL");
    }

    SDL_SetEventFilter(SDLHandleAppEvents, nullptr);

    DebugLog(-1, "SDL initialized...");

    SDL_LogSetAllPriority(SDL_LOG_PRIORITY_WARN);

    // on demand now
    //extern bool sfxr_init();
    //if (!sfxr_init())
    //   return SDLError("Unable to initialize audio");

    #ifdef PLATFORM_MOBILE
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
    #else
    //certain older Intel HD GPUs and also Nvidia Quadro 1000M don't support 3.1 ? the 1000M is supposed to support 4.2
    //SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
    //SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
    #ifndef WIN32
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG);
    #endif
    SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
    SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4);
    #endif

    //SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0);      // set this if we're in 2D mode for speed on mobile?
    SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, 1);    // because we redraw the screen each frame

    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

    DebugLog(-1, "SDL about to figure out display mode...");

    #ifdef PLATFORM_MOBILE
    landscape = screensize.x() >= screensize.y();
    int modes = SDL_GetNumDisplayModes(0);
    screensize = int2(0);
    for (int i = 0; i < modes; i++)
    {
        SDL_DisplayMode mode;
        SDL_GetDisplayMode(0, i, &mode);
        //printf("mode: %d %d\n", mode.w, mode.h);
        if (landscape ? mode.w > screensize.x() : mode.h > screensize.y())
        {
            screensize = int2(mode.w, mode.h);
        }
    }

    DebugLog(-1, inttoa(screensize.x()));
    DebugLog(-1, inttoa(screensize.y()));
    DebugLog(-1, "SDL about to create window...");

    _sdl_window = SDL_CreateWindow(title,
                                    0, 0,
                                    screensize.x(), screensize.y(),
                                    SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS);

    DebugLog(-1, _sdl_window ? "SDL window passed..." : "SDL window FAILED...");

    if (landscape) SDL_SetHint("SDL_HINT_ORIENTATIONS", "LandscapeLeft LandscapeRight");

    int ax = 0, ay = 0;
    SDL_GetWindowSize(_sdl_window, &ax, &ay);
    int2 actualscreensize(ax, ay);
    //screenscalefactor = screensize.x / actualscreensize.x;  // should be 2 on retina
    #ifdef __IOS__
        assert(actualscreensize == screensize);
        screensize = actualscreensize;
    #else
        screensize = actualscreensize;  // __ANDROID__
        DebugLog(-1, inttoa(screensize.x()));
        DebugLog(-1, inttoa(screensize.y()));
    #endif
    #else
    _sdl_window = SDL_CreateWindow(title,
                                    SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
                                    screensize.x(), screensize.y(),
                                    SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE |
                                        (fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0));
    #endif

    if (!_sdl_window)
        return SDLError("Unable to create window");

    DebugLog(-1, "SDL window opened...");


    _sdl_context = SDL_GL_CreateContext(_sdl_window);
    DebugLog(-1, _sdl_context ? "SDL context passed..." : "SDL context FAILED...");
    if (!_sdl_context) return SDLError("Unable to create OpenGL context");

    DebugLog(-1, "SDL OpenGL context created...");

    /*
    SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
    SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4);
    */

    #ifndef __IOS__
        SDL_GL_SetSwapInterval(1);  // vsync on
    #endif

    SDL_JoystickEventState(SDL_ENABLE);
    SDL_JoystickUpdate();
    for(int i = 0; i < SDL_NumJoysticks(); i++)
    {
        SDL_Joystick *joy;
        if (joy = SDL_JoystickOpen(i))
        {
            DebugLog(-1, "Detected joystick: %s (%d axes, %d buttons, %d balls, %d hats)\n",
                         SDL_JoystickName(joy), SDL_JoystickNumAxes(joy), SDL_JoystickNumButtons(joy),
                         SDL_JoystickNumBalls(joy), SDL_JoystickNumHats(joy));
        };
    };

    starttime = SDL_GetTicks();
    lastmillis = starttime - 16;    // ensure first frame doesn't get a crazy delta

    return "";
}
예제 #4
0
void HelloScene::OnOptionButtonClick(CBView* item,int index)
{
	DebugLog("HelloScene::OnOptionButtonClick [%d]\n",index);
}
예제 #5
0
파일: X3100.cpp 프로젝트: Beshuta/HWSensors
bool X3100monitor::start(IOService * provider)
{
	if (!provider || !super::start(provider)) return false;
	
	if (!(fakeSMC = waitForService(serviceMatching(kFakeSMCDeviceService)))) {
		WarningLog("Can't locate fake SMC device, kext will not load");
		return false;
	}
	
	IOMemoryDescriptor *		theDescriptor;
	IOPhysicalAddress bar = (IOPhysicalAddress)((VCard->configRead32(kMCHBAR)) & ~0xf);
	DebugLog("Fx3100: register space=%08lx\n", (long unsigned int)bar);
	theDescriptor = IOMemoryDescriptor::withPhysicalAddress (bar, 0x2000, kIODirectionOutIn); // | kIOMapInhibitCache);
	if(theDescriptor != NULL)
	{
		mmio = theDescriptor->map();
		if(mmio != NULL)
		{
			mmio_base = (volatile UInt8 *)mmio->getVirtualAddress();
#if DEBUG				
			DebugLog(" MCHBAR mapped\n");
			for (int i=0; i<0x2f; i +=16) {
				DebugLog("%04lx: ", (long unsigned int)i+0x1000);
				for (int j=0; j<16; j += 1) {
					DebugLog("%02lx ", (long unsigned int)INVID8(i+j+0x1000));
				}
				DebugLog("\n");
			}
#endif				
		}
		else
		{
			InfoLog(" MCHBAR failed to map\n");
			return -1;
		}			
	}	
	
	char name[5];
	//try to find empty key
	for (int i = 0; i < 0x10; i++) {
						
		snprintf(name, 5, KEY_FORMAT_GPU_DIODE_TEMPERATURE, i); 
			
		UInt8 length = 0;
		void * data = 0;
			
		IOReturn result = fakeSMC->callPlatformFunction(kFakeSMCGetKeyValue, true, (void *)name, (void *)&length, (void *)&data, 0);
			
		if (kIOReturnSuccess == result) {
			continue;
		}
		if (addSensor(name, TYPE_SP78, 2, i)) {
			numCard = i;
			break;
		}
	}
		
	if (kIOReturnSuccess != fakeSMC->callPlatformFunction(kFakeSMCAddKeyHandler, false, (void *)name, (void *)TYPE_SP78, (void *)2, this)) {
		WarningLog("Can't add key to fake SMC device, kext will not load");
		return false;
	}
	
	return true;	
}
CGameLoaderHandler::~CGameLoaderHandler()
{
	UnloadGame();
	
	DebugLog("Destructing the game loader component...");
};
예제 #7
0
CFileSystem::~CFileSystem()
{
	DebugLog("CFileSystem::~CFileSystem");
};
void IntelMausi::intelSetupRxControl(struct e1000_adapter *adapter)
{
	struct e1000_hw *hw = &adapter->hw;
	u32 rctl, rfctl;
    
	/* Workaround Si errata on PCHx - configure jumbo frame flow.
	 * If jumbo frames not set, program related MAC/PHY registers
	 * to h/w defaults
	 */
	if (hw->mac.type >= e1000_pch2lan) {
		s32 ret_val;
        
		if (mtu > ETH_DATA_LEN)
			ret_val = e1000_lv_jumbo_workaround_ich8lan(hw, true);
		else
			ret_val = e1000_lv_jumbo_workaround_ich8lan(hw, false);
        
		if (ret_val)
			DebugLog("Ethernet [IntelMausi]: failed to enable/disable jumbo frame workaround mode.\n");
	}
	/* Program MC offset vector base */
	rctl = intelReadMem32(E1000_RCTL);
	rctl &= ~(3 << E1000_RCTL_MO_SHIFT);
	rctl |= E1000_RCTL_BAM | E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF | (adapter->hw.mac.mc_filter_type << E1000_RCTL_MO_SHIFT);
    
	/* Do not Store bad packets */
	rctl &= ~E1000_RCTL_SBP;
    
	/* Enable Long Packet receive */
	if (mtu <= ETH_DATA_LEN)
		rctl &= ~E1000_RCTL_LPE;
	else
		rctl |= E1000_RCTL_LPE;
    
	/* Some systems expect that the CRC is included in SMBUS traffic. The
	 * hardware strips the CRC before sending to both SMBUS (BMC) and to
	 * host memory when this is enabled
	 */
	if (adapter->flags2 & FLAG2_CRC_STRIPPING)
        rctl |= E1000_RCTL_SECRC;
    
	/* Workaround Si errata on 82577 PHY - configure IPG for jumbos */
	if ((hw->phy.type == e1000_phy_82577) && (rctl & E1000_RCTL_LPE)) {
		u16 phy_data;
        
		e1e_rphy(hw, PHY_REG(770, 26), &phy_data);
		phy_data &= 0xfff8;
		phy_data |= (1 << 2);
		e1e_wphy(hw, PHY_REG(770, 26), phy_data);
        
		e1e_rphy(hw, 22, &phy_data);
		phy_data &= 0x0fff;
		phy_data |= (1 << 14);
		e1e_wphy(hw, 0x10, 0x2823);
		e1e_wphy(hw, 0x11, 0x0003);
		e1e_wphy(hw, 22, phy_data);
	}
    
	/* Set buffer sizes to 2048 */
    //rctl |= (0x2 << E1000_RCTL_FLXB_SHIFT);
    rctl &= ~(E1000_RCTL_SZ_256 | E1000_RCTL_BSEX);
    
	/* Enable Extended Status in all Receive Descriptors */
	rfctl = intelReadMem32(E1000_RFCTL);
    rfctl |= (E1000_RFCTL_NEW_IPV6_EXT_DIS | E1000_RFCTL_IPV6_EX_DIS | E1000_RFCTL_EXTEN | E1000_RFCTL_NFSW_DIS | E1000_RFCTL_NFSR_DIS);
	intelWriteMem32(E1000_RFCTL, rfctl);
    
	intelWriteMem32(E1000_RCTL, rctl);
}
예제 #9
0
void load_auto_pickup(bool bCharacter)
{
    std::ifstream fin;
    std::string sFile = "data/auto_pickup.txt";

    if (bCharacter) {
        sFile = "save/" + base64_encode(g->u.name) + ".apu.txt";
    }

    fin.open(sFile.c_str());
    if(!fin.is_open()) {
        fin.close();

        create_default_auto_pickup(bCharacter);

        fin.open(sFile.c_str());
        if(!fin.is_open()) {
            DebugLog() << "Could neither read nor create " << sFile << "\n";
            return;
        }
    }

    vAutoPickupRules[(bCharacter) ? 2 : 1].clear();

    std::string sLine;
    while(!fin.eof()) {
        getline(fin, sLine);

        if(sLine != "" && sLine[0] != '#') {
            int iNum = std::count(sLine.begin(), sLine.end(), ';');

            if(iNum != 2) {
                /*int iNum = std::count(sLine.begin(), sLine.end(), ' ');

                if(iNum == 1) { //its an option! hurray

                } else {*/
                    DebugLog() << "Bad Rule: " << sLine << "\n";
                //}

            } else {
                std::string sRule = "";
                bool bActive = true;
                bool bExclude = false;

                size_t iPos = 0;
                int iCol = 1;
                do {
                    iPos = sLine.find(";");

                    std::string sTemp = (iPos == std::string::npos) ? sLine : sLine.substr(0, iPos);

                    if (iCol == 1) {
                        sRule = sTemp;

                    } else if (iCol == 2) {
                        bActive = (sTemp == "T" || sTemp == "True") ? true : false;

                    } else if (iCol == 3) {
                        bExclude = (sTemp == "T" || sTemp == "True") ? true : false;
                    }

                    iCol++;

                    if (iPos != std::string::npos) {
                        sLine = sLine.substr(iPos+1, sLine.size());
                    }

                } while(iPos != std::string::npos);

                vAutoPickupRules[(bCharacter) ? 2 : 1].push_back(cPickupRules(sRule, bActive, bExclude));
            }
        }
    }

    fin.close();

    merge_vector();
    createPickupRules();
}
예제 #10
0
// |----------------------------------------------------------------------------|
// |							   Initialize									|
// |----------------------------------------------------------------------------|
bool Player::Initialize() {
    GameObject::Initialize();

	// Set up ship
	Graphic* graphic = new Graphic;
    graphic->SetTint(1.0f,1.0f,1.0f,1.0f);
    graphic->SetShader("Texture");
    graphic->SetShader("Light");
	graphic->SetTexture("shiptexture");
    graphic->SetModel("ship");
    graphic->SetScale(Coord(0.01f,0.01f,0.01f));
	graphic->SetReflectiveness(0.95f);
    graphic->Initialize();
    m_ship = new GameObject;
    m_ship->Initialize();
	m_ship->SetGraphic(graphic);
    m_ship->SetPosition(Coord(0.0f,0.0f,0.0f));
    m_ship->SetOrientation(Coord(0.0f,0.0f,0.0f));

    // Set up left thruster
    m_leftThruster = new ParticleSystem;
    m_leftThruster->Initialize();
    graphic = new Billboard;
    graphic->SetShader("Texture");
    graphic->SetTexture("fireball");
    graphic->SetAlphaBlend(true);
    graphic->SetScale(Coord(0.003f,0.003f,0.003f));
    graphic->Initialize();
    m_leftThruster->SetGraphic(graphic);
    m_leftThruster->SetPosition(Coord(-0.6f,0.0f,-0.7f));
    m_leftThruster->SetParticleVelocity(Coord(0.0f,0.0f,-2.0f));
    m_leftThruster->SetParticleVelocityVariation(Coord(0.5f,0.5f,0.5f));
    m_leftThruster->SetParticleSpawnFrequency(0.01f);
    m_leftThruster->SetParticleDeviation(Coord(0.0f,0.0f,0.0f));
    m_leftThruster->SetParticleLifetime(0.5f);
    m_leftThruster->SetParticleFadeout(0.2f);
    m_leftThruster->SetMaxParticles(100);
    m_leftThruster->SetTint(0.8f,0.9f,1.0f);
    m_leftThruster->SetTintVar(0.2f,0.2f,0.2f);

    // Set up right thruster
    m_rightThruster = new ParticleSystem;
    m_rightThruster->Initialize();
    graphic = new Billboard;
    graphic->SetShader("Texture");
    graphic->SetTexture("fireball");
    graphic->SetAlphaBlend(true);
    graphic->SetScale(Coord(0.003f,0.003f,0.003f));
    graphic->Initialize();
    m_rightThruster->SetGraphic(graphic);
    m_rightThruster->SetPosition(Coord(0.6f,0.0f,-0.7f));
    m_rightThruster->SetParticleVelocity(Coord(0.0f,0.0f,-2.0f));
    m_rightThruster->SetParticleVelocityVariation(Coord(0.5f,0.5f,0.5f));
    m_rightThruster->SetParticleSpawnFrequency(0.001f);
    m_rightThruster->SetParticleDeviation(Coord(0.0f,0.0f,0.0f));
    m_rightThruster->SetParticleLifetime(0.5f);
    m_rightThruster->SetParticleFadeout(0.2f);
    m_rightThruster->SetMaxParticles(100);
    m_rightThruster->SetTint(0.8f,0.9f,1.0f);
    m_rightThruster->SetTintVar(0.2f,0.2f,0.2f);



	DebugLog ("Player: object initialized.");
	return true;
}
void IntelMausi::intelDisable()
{
    struct e1000_hw *hw = &adapterData.hw;
    UInt32 wufc = adapterData.wol;
    UInt32 ctrl, ctrlExt, rctl, status;
    
    /* Flush LPIC. */
    intelFlushLPIC();

    status = intelReadMem32(E1000_STATUS);
    
    if (status & E1000_STATUS_LU)
        wufc &= ~E1000_WUFC_LNKC;

    if (wolActive && wufc) {
        intelDown(&adapterData, false);
        intelSetupRxControl(&adapterData);
        
        rctl = intelReadMem32(E1000_RCTL);
        rctl &= ~(E1000_RCTL_UPE | E1000_RCTL_MPE);
        
        /* turn on all-multi mode if wake on multicast is enabled */
        if (wufc & E1000_WUFC_MC)
            rctl |= E1000_RCTL_MPE;

        intelWriteMem32(E1000_RCTL, rctl);

        ctrl = intelReadMem32(E1000_CTRL);
        ctrl |= E1000_CTRL_ADVD3WUC;
        
        if (!(adapterData.flags2 & FLAG2_HAS_PHY_WAKEUP))
            ctrl |= E1000_CTRL_EN_PHY_PWR_MGMT;
        
        intelWriteMem32(E1000_CTRL, ctrl);
        
        if (adapterData.hw.phy.media_type == e1000_media_type_fiber ||
            adapterData.hw.phy.media_type == e1000_media_type_internal_serdes) {
            /* keep the laser running in D3 */
            ctrlExt = intelReadMem32(E1000_CTRL_EXT);
            ctrlExt |= E1000_CTRL_EXT_SDP3_DATA;
            intelWriteMem32(E1000_CTRL_EXT, ctrlExt);
        }
        if (adapterData.flags & FLAG_IS_ICH)
            e1000_suspend_workarounds_ich8lan(hw);
        
        if (adapterData.flags2 & FLAG2_HAS_PHY_WAKEUP) {
            /* enable wakeup by the PHY */
            intelInitPhyWakeup(wufc);
        } else {
            /* enable wakeup by the MAC */
            intelWriteMem32(E1000_WUFC, wufc);
            intelWriteMem32(E1000_WUC, E1000_WUC_PME_EN);
        }
        DebugLog("Ethernet [IntelMausi]: WUFC=0x%08x.\n", wufc);
    } else {
        intelDown(&adapterData, true);
        intelWriteMem32(E1000_WUC, 0);
        intelWriteMem32(E1000_WUFC, 0);
        intelPowerDownPhy(&adapterData);
    }
    /* If AMT is enabled, let the firmware know that the network
     * interface is now closed
     */
    if (adapterData.flags & FLAG_HAS_AMT)
        e1000e_release_hw_control(&adapterData);
}
예제 #12
0
// |----------------------------------------------------------------------------|
// |							   Destructor									|
// |----------------------------------------------------------------------------|
Player::~Player() {
	DebugLog ("Player: object destroyed.");
}
예제 #13
0
// |----------------------------------------------------------------------------|
// |							  Copy Constructor								|
// |----------------------------------------------------------------------------|
Player::Player(const Player&) {
	DebugLog ("Player: object copied.");
}
예제 #14
0
// |----------------------------------------------------------------------------|
// |							    Shutdown									|
// |----------------------------------------------------------------------------|
bool Player::Shutdown() {
    GameObject::Shutdown();
	DebugLog ("Player: object shutdown.");
	return true;
}
예제 #15
0
// |----------------------------------------------------------------------------|
// |							   Destructor									|
// |----------------------------------------------------------------------------|
ParticleSystem::~ParticleSystem() {
    DebugLog ("ParticleSystem: object destroyed.");
}
예제 #16
0
IOReturn BrcmPatchRAM::hciCommand(void * command, UInt16 length)
{
    IOReturn result;
    
    IOUSBDevRequest request =
    {
        .bmRequestType = USBmakebmRequestType(kUSBOut, kUSBClass, kUSBDevice),
        .bRequest = 0,
        .wValue = 0,
        .wIndex = 0,
        .wLength = length,
        .pData = command
    };
    
    if ((result = mInterface->DeviceRequest(&request)) != kIOReturnSuccess)
        AlwaysLog("[%04x:%04x]: device request failed (\"%s\" 0x%08x).\n", mVendorId, mProductId, stringFromReturn(result), result);
    
    return result;
}

IOReturn BrcmPatchRAM::hciParseResponse(void* response, UInt16 length, void* output, UInt8* outputLength)
{
    HCI_RESPONSE* header = (HCI_RESPONSE*)response;
    IOReturn result = kIOReturnSuccess;

    switch (header->eventCode)
    {
        case HCI_EVENT_COMMAND_COMPLETE:
        {
            HCI_COMMAND_COMPLETE* event = (HCI_COMMAND_COMPLETE*)response;
            
            switch (event->opcode)
            {
                case HCI_OPCODE_READ_VERBOSE_CONFIG:
                    DebugLog("[%04x:%04x]: READ VERBOSE CONFIG complete (status: 0x%02x, length: %d bytes).\n",
                             mVendorId, mProductId, event->status, header->length);
                    
                    mFirmareVersion = *(UInt16*)(((char*)response) + 10);
                    
                    DebugLog("[%04x:%04x]: Firmware version: v%d.\n",
                             mVendorId, mProductId, mFirmareVersion + 0x1000);
                    
                    // Device does not require a firmware patch at this time
                    if (mFirmareVersion > 0)
                        mDeviceState = kUpdateComplete;
                    else
                        mDeviceState = kFirmwareVersion;
                    break;
                case HCI_OPCODE_DOWNLOAD_MINIDRIVER:
                    DebugLog("[%04x:%04x]: DOWNLOAD MINIDRIVER complete (status: 0x%02x, length: %d bytes).\n",
                             mVendorId, mProductId, event->status, header->length);
                    
                    mDeviceState = kMiniDriverComplete;
                    break;
                case HCI_OPCODE_LAUNCH_RAM:
                    //DebugLog("[%04x:%04x]: LAUNCH RAM complete (status: 0x%02x, length: %d bytes).\n",
                    //          mVendorId, mProductId, event->status, header->length);
                    
                    mDeviceState = kInstructionWritten;
                    break;
                case HCI_OPCODE_END_OF_RECORD:
                    DebugLog("[%04x:%04x]: END OF RECORD complete (status: 0x%02x, length: %d bytes).\n",
                             mVendorId, mProductId, event->status, header->length);
                    
                    mDeviceState = kFirmwareWritten;
                    break;
                case HCI_OPCODE_RESET:
                    DebugLog("[%04x:%04x]: RESET complete (status: 0x%02x, length: %d bytes).\n",
                             mVendorId, mProductId, event->status, header->length);
                    
                    mDeviceState = kResetComplete;
                    break;
                default:
                    DebugLog("[%04x:%04x]: Event COMMAND COMPLETE (opcode 0x%04x, status: 0x%02x, length: %d bytes).\n",
                             mVendorId, mProductId, event->opcode, event->status, header->length);
                    break;
            }
            
            if (output && outputLength)
            {
                bzero(output, *outputLength);
                
                // Return the received data
                if (*outputLength >= length)
                {
                    DebugLog("[%04x:%04x]: Returning output data %d bytes.\n", mVendorId, mProductId, length);
                    
                    *outputLength = length;
                    memcpy(output, response, length);
                }
                else
                    // Not enough buffer space for data
                    result = kIOReturnMessageTooLarge;
            }
            break;
        }
        case HCI_EVENT_NUM_COMPLETED_PACKETS:
            DebugLog("[%04x:%04x]: Number of completed packets.\n", mVendorId, mProductId);
            break;
        case HCI_EVENT_CONN_COMPLETE:
            DebugLog("[%04x:%04x]: Connection complete event.\n", mVendorId, mProductId);
            break;
        case HCI_EVENT_DISCONN_COMPLETE:
            DebugLog("[%04x:%04x]: Disconnection complete. event\n", mVendorId, mProductId);
            break;
        case HCI_EVENT_HARDWARE_ERROR:
            DebugLog("[%04x:%04x]: Hardware error\n", mVendorId, mProductId);
            break;
        case HCI_EVENT_MODE_CHANGE:
            DebugLog("[%04x:%04x]: Mode change event.\n", mVendorId, mProductId);
            break;
        case HCI_EVENT_LE_META:
            DebugLog("[%04x:%04x]: Low-Energy meta event.\n", mVendorId, mProductId);
            break;
        default:
            DebugLog("[%04x:%04x]: Unknown event code (0x%02x).\n", mVendorId, mProductId, header->eventCode);
            break;
    }
    
    return result;
}
CGameLoaderHandler::CGameLoaderHandler()
{
	DebugLog("Constructing the game loader component...");
};
예제 #18
0
bool BrcmPatchRAM::performUpgrade()
{
    BrcmFirmwareStore* firmwareStore;
    OSArray* instructions = NULL;
    OSCollectionIterator* iterator = NULL;
    OSData* data;
#ifdef DEBUG
    DeviceState previousState = kUnknown;
#endif

    IOLockLock(mCompletionLock);
    mDeviceState = kInitialize;

    while (true)
    {
#ifdef DEBUG
        if (mDeviceState != kInstructionWrite && mDeviceState != kInstructionWritten)
            DebugLog("[%04x:%04x]: State \"%s\" --> \"%s\".\n", mVendorId, mProductId, getState(previousState), getState(mDeviceState));
        previousState = mDeviceState;
#endif

        // Break out when done
        if (mDeviceState == kUpdateAborted || mDeviceState == kUpdateComplete)
            break;

        // Note on following switch/case:
        //   use 'break' when a response from io completion callback is expected
        //   use 'continue' when a change of state with no expected response (loop again)

        switch (mDeviceState)
        {
            case kInitialize:
                hciCommand(&HCI_VSC_READ_VERBOSE_CONFIG, sizeof(HCI_VSC_READ_VERBOSE_CONFIG));
                break;

            case kFirmwareVersion:
                // Unable to retrieve firmware store
                if (!(firmwareStore = getFirmwareStore()))
                {
                    mDeviceState = kUpdateAborted;
                    continue;
                }
                instructions = firmwareStore->getFirmware(OSDynamicCast(OSString, getProperty(kFirmwareKey)));
                // Unable to retrieve firmware instructions
                if (!instructions)
                {
                    mDeviceState = kUpdateAborted;
                    continue;
                }

                // Initiate firmware upgrade
                hciCommand(&HCI_VSC_DOWNLOAD_MINIDRIVER, sizeof(HCI_VSC_DOWNLOAD_MINIDRIVER));
                break;

            case kMiniDriverComplete:
                // Write firmware data to bulk pipe
                iterator = OSCollectionIterator::withCollection(instructions);
                if (!iterator)
                {
                    mDeviceState = kUpdateAborted;
                    continue;
                }

                // If this IOSleep is not issued, the device is not ready to receive
                // the firmware instructions and we will deadlock due to lack of
                // responses.
                IOSleep(10);

                // Write first 2 instructions to trigger response
                if ((data = OSDynamicCast(OSData, iterator->getNextObject())))
                    bulkWrite(data->getBytesNoCopy(), data->getLength());
                if ((data = OSDynamicCast(OSData, iterator->getNextObject())))
                    bulkWrite(data->getBytesNoCopy(), data->getLength());
                break;

            case kInstructionWrite:
                // should never happen, but would cause a crash
                if (!iterator)
                {
                    mDeviceState = kUpdateAborted;
                    continue;
                }

                if ((data = OSDynamicCast(OSData, iterator->getNextObject())))
                    bulkWrite(data->getBytesNoCopy(), data->getLength());
                else
                    // Firmware data fully written
                    hciCommand(&HCI_VSC_END_OF_RECORD, sizeof(HCI_VSC_END_OF_RECORD));
                break;

            case kInstructionWritten:
                mDeviceState = kInstructionWrite;
                continue;

            case kFirmwareWritten:
                hciCommand(&HCI_RESET, sizeof(HCI_RESET));
                break;

            case kResetComplete:
                resetDevice();
                getDeviceStatus();
                mDeviceState = kUpdateComplete;
                continue;

            case kUnknown:
            case kUpdateComplete:
            case kUpdateAborted:
                DebugLog("Error: kUnkown/kUpdateComplete/kUpdateAborted cases should be unreachable.\n");
                break;
        }

        // queue async read
        if (!continuousRead())
        {
            mDeviceState = kUpdateAborted;
            continue;
        }
        // wait for completion of the async read
        IOLockSleep(mCompletionLock, NULL, 0);
    }

    IOLockUnlock(mCompletionLock);
    OSSafeRelease(iterator);

    return mDeviceState == kUpdateComplete;
}
예제 #19
0
CFileSystem::CFileSystem(ILowLevelFileSystem *apLowLevelFileSystem)
{
	mpLowLevelFileSystem = apLowLevelFileSystem;
	
	DebugLog("CFileSystem::CFileSystem");
};
예제 #20
0
std::string mod_ui::get_information( MOD_INFORMATION *mod )
{
    if( mod == NULL ) {
        return "";
    }
    std::string modident = mod->ident;
    std::string note = ( !mm_tree->is_available( modident ) ) ? mm_tree->get_node(
                           modident )->s_errors() : "";

    std::ostringstream info;

    // color the note red!
    if( !note.empty() ) {
        std::stringstream newnote;
        newnote << "<color_red>" << note << "</color>";
        note = newnote.str();
    }
    std::vector<std::string> dependencies = mod->dependencies;
    std::vector<std::string> authors = mod->authors;
    std::string description = mod->description;
    std::string dependency_string = "";
    if( !dependencies.empty() ) {
        DebugLog( D_PEDANTIC_INFO, DC_ALL ) << mod->name << " Dependencies --";
        for( size_t i = 0; i < dependencies.size(); ++i ) {
            if( i > 0 ) {
                //~ delimiter for mod dependency enumeration
                dependency_string += pgettext( "mod manager", ", " );
            }
            DebugLog( D_PEDANTIC_INFO, DC_ALL ) << "\t" << dependencies[i];
            if( active_manager->mod_map.find( dependencies[i] ) != active_manager->mod_map.end() ) {
                dependency_string += "[" + active_manager->mod_map[dependencies[i]]->name + "]";
            } else {
                dependency_string += "[<color_red>" + dependencies[i] + "</color>]";
            }
        }
        DebugLog( D_PEDANTIC_INFO, DC_ALL ) << "\n";
    }
    std::string author_string = "";
    if( !authors.empty() ) {
        for( size_t i = 0; i < authors.size(); ++i ) {
            if( i > 0 ) {
                //~ delimiter for mod author enumeration
                author_string += pgettext( "mod manager", ", " );
            }
            author_string += authors[i];
        }
        info << string_format( ngettext( "Author: %s\n", "Authors: %s\n", authors.size() ),
                               author_string.c_str() );
    } else {
        info << _( "Authors: [UNKNOWN]\n" );
    }

    if( !dependencies.empty() ) {
        info << string_format( ngettext( "Dependency: %s\n", "Dependencies: %s\n", dependencies.size() ),
                               dependency_string.c_str() );
    } else {
        info << _( "Dependencies: [NONE]\n" );
    }

    if( !description.empty() ) {
        info << string_format( _( "Description: %s\n" ), description.c_str() );
    } else {
        info << _( "Description: [NONE]\n" );
    }

    if( mod->_type == MT_SUPPLEMENTAL && !note.empty() ) {
        info << note;
    }

#ifndef LUA
    if( mod->need_lua ) {
        std::string lua_msg = "";
        lua_msg += "<color_red>";
        lua_msg += _( "This mod requires Lua but your CDDA build doesn't support it!" );
        lua_msg += "</color>";
        info << lua_msg;
    }
#endif
    return info.str();
}
예제 #21
0
//Basic Init, create the font, backbuffer, etc
WINDOW *curses_init(void)
{
   // _windows = new WINDOW[20];         //initialize all of our variables
    lastchar=-1;
    inputdelay=-1;

    int fontsize = 16;
    std::string typeface;
    int map_fontwidth = 8;
    int map_fontheight = 16;
    int map_fontsize = 16;
    std::string map_typeface;
    int overmap_fontwidth = 8;
    int overmap_fontheight = 16;
    int overmap_fontsize = 16;
    std::string overmap_typeface;
    bool fontblending;

    std::ifstream jsonstream(FILENAMES["fontdata"].c_str(), std::ifstream::binary);
    if (jsonstream.good()) {
        JsonIn json(jsonstream);
        JsonObject config = json.get_object();
        // fontsize, fontblending, map_* are ignored in wincurse.
        fontwidth = config.get_int("fontwidth", fontwidth);
        fontheight = config.get_int("fontheight", fontheight);
        typeface = config.get_string("typeface", typeface);
        jsonstream.close();
    } else { // User fontdata is missed. Try to load legacy fontdata.
        // Get and save all values. With unused.
        std::ifstream InStream(FILENAMES["legacy_fontdata"].c_str(), std::ifstream::binary);
        if(InStream.good()) {
            JsonIn jIn(InStream);
            JsonObject config = jIn.get_object();
            fontwidth = config.get_int("fontwidth", fontwidth);
            fontheight = config.get_int("fontheight", fontheight);
            fontsize = config.get_int("fontsize", fontsize);
            typeface = config.get_string("typeface", typeface);
            map_fontwidth = config.get_int("map_fontwidth", fontwidth);
            map_fontheight = config.get_int("map_fontheight", fontheight);
            map_fontsize = config.get_int("map_fontsize", fontsize);
            map_typeface = config.get_string("map_typeface", typeface);
            overmap_fontwidth = config.get_int("overmap_fontwidth", fontwidth);
            overmap_fontheight = config.get_int("overmap_fontheight", fontheight);
            overmap_fontsize = config.get_int("overmap_fontsize", fontsize);
            overmap_typeface = config.get_string("overmap_typeface", typeface);
            InStream.close();
            // Save legacy as user fontdata.
            assure_dir_exist(FILENAMES["config_dir"]);
            std::ofstream OutStream(FILENAMES["fontdata"].c_str(), std::ofstream::binary);
            if(!OutStream.good()) {
                DebugLog( D_ERROR, DC_ALL ) << "Can't save user fontdata file.\n"
                << "Check permissions for: " << FILENAMES["fontdata"].c_str();
                return NULL;
            }
            JsonOut jOut(OutStream, true); // pretty-print
            jOut.start_object();
            jOut.member("fontblending", fontblending);
            jOut.member("fontwidth", fontwidth);
            jOut.member("fontheight", fontheight);
            jOut.member("fontsize", fontsize);
            jOut.member("typeface", typeface);
            jOut.member("map_fontwidth", map_fontwidth);
            jOut.member("map_fontheight", map_fontheight);
            jOut.member("map_fontsize", map_fontsize);
            jOut.member("map_typeface", map_typeface);
            jOut.member("overmap_fontwidth", overmap_fontwidth);
            jOut.member("overmap_fontheight", overmap_fontheight);
            jOut.member("overmap_fontsize", overmap_fontsize);
            jOut.member("overmap_typeface", overmap_typeface);
            jOut.end_object();
            OutStream << "\n";
            OutStream.close();
        } else {
            DebugLog( D_ERROR, DC_ALL ) << "Can't load fontdata files.\n"
            << "Check permissions for:\n" << FILENAMES["legacy_fontdata"].c_str() << "\n"
            << FILENAMES["fontdata"].c_str() << "\n";
            return NULL;
        }
    }

    halfwidth=fontwidth / 2;
    halfheight=fontheight / 2;
    WindowWidth= OPTIONS["TERMINAL_X"] * fontwidth;
    WindowHeight = OPTIONS["TERMINAL_Y"] * fontheight;

    WinCreate();    //Create the actual window, register it, etc
    timeBeginPeriod(1); // Set Sleep resolution to 1ms
    CheckMessages();    //Let the message queue handle setting up the window

    WindowDC   = GetDC(WindowHandle);
    backbuffer = CreateCompatibleDC(WindowDC);

    BITMAPINFO bmi = BITMAPINFO();
    bmi.bmiHeader.biSize         = sizeof(BITMAPINFOHEADER);
    bmi.bmiHeader.biWidth        = WindowWidth;
    bmi.bmiHeader.biHeight       = -WindowHeight;
    bmi.bmiHeader.biPlanes       = 1;
    bmi.bmiHeader.biBitCount     = 8;
    bmi.bmiHeader.biCompression  = BI_RGB; // Raw RGB
    bmi.bmiHeader.biSizeImage    = WindowWidth * WindowHeight * 1;
    bmi.bmiHeader.biClrUsed      = 16; // Colors in the palette
    bmi.bmiHeader.biClrImportant = 16; // Colors in the palette
    backbit = CreateDIBSection(0, &bmi, DIB_RGB_COLORS, (void**)&dcbits, NULL, 0);
    DeleteObject(SelectObject(backbuffer, backbit));//load the buffer into DC

    // Load private fonts
    if (SetCurrentDirectoryW(L"data\\font")){
        WIN32_FIND_DATA findData;
        for (HANDLE findFont = FindFirstFileW(L".\\*", &findData); findFont != INVALID_HANDLE_VALUE; )
        {
            if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)){ // Skip folders
                AddFontResourceExW(findData.cFileName, FR_PRIVATE,NULL);
            }
            if (!FindNextFile(findFont, &findData)){
                FindClose(findFont);
                break;
            }
        }
        SetCurrentDirectoryW(L"..\\..");
    }

    // Use desired font, if possible
    font = CreateFontW(fontheight, fontwidth, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
                      DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,
                      PROOF_QUALITY, FF_MODERN, widen(typeface).c_str());

    SetBkMode(backbuffer, TRANSPARENT);//Transparent font backgrounds
    SelectObject(backbuffer, font);//Load our font into the DC
//    WindowCount=0;

    init_colors();

    mainwin = newwin(OPTIONS["TERMINAL_Y"],OPTIONS["TERMINAL_X"],0,0);
    return mainwin;   //create the 'stdscr' window and return its ref
}
예제 #22
0
void CodecCommanderClient::stop(IOService * provider)
{
    DebugLog("Client::stop\n");
    
    super::stop(provider);
}
예제 #23
0
static void gui_focus_event(winlist_t *win, XEvent *event)
{
    switch (event->type)
    {
	case MapNotify:
	    DebugLog(1, ("MapNotify\n"));
	    if (!tray_init)
	    {
		XUnmapWindow(gui->display, win->window);
		alarm(1);
	    }
	    break;
	case UnmapNotify:
	    DebugLog(1, ("UnMapNotify\n"));
	    break;
	case ReparentNotify:
	    DebugLog(1, ("ReparentNotify Root(%d), Event_win(%d), Parent_Win(%d)\n", gui->root, event->xreparent.event, event->xreparent.parent));
	    parent_window = event->xreparent.parent;
	    if (parent_window == gui->root)
	    {
		DebugLog(1, ("Escape Manager Window\n"));
		tray_init = False;
	    }
	    break;
	case ConfigureNotify:
	case MotionNotify: /* Mouse Over */
	    {
	    XConfigureEvent *e = &event->xconfigure;
	    DebugLog(1, ("(my %d) ConfigureNotify manager=%d, Window=%d, x=%d, y=%d, w=%d, h=%d, border_w:%d, aboveWin=%d, override=%d\n",win->window, manager_window, e->window, e->x, e->y, e->width, e->height, e->border_width, e->above, e->override_redirect));
 		// width, height 會被改變,所以這裡要偵測大小是否被改變了
		// 有的話要重新把圖示放在新的範圍中間
		if (win->window == e->window && (win->width != e->width || win->height != e->height))
		{
		    DebugLog(1, ("Window size changed!\n"));
/*
		    int sw = (e->width - win->width) / 2;
		    int sh = (e->height - win->height) / 2;
		    int new_x = (sw > 1) ? sw : 0;
		    int new_y = (sh > 1) ? sh : 0;
		    XMoveWindow(gui->display, win->window, new_x, new_y);
*/
		    win->width = e->width;
		    win->height = e->height;
		}
	    gui_reread_resolution(win);
	    }
	    break;
//	case MotionNotify: /* Mouse Over */
//	    break;
	case EnterNotify: /* Mouse In */
	    DebugLog(1, ("EnterNotify\n"));
	    if (!gui_msgbox_actived() && !gui_menu_actived() )
	    {
		static char s[20];
		strcpy(s, "OXIM");
		strcat(s, " ");
		strcat(s, oxim_version());
		gui_show_msgbox(win, s);
	    }
	    break;
	case LeaveNotify: /* Mouse Out */
	    if (gui_msgbox_actived())
	    {
		gui_hide_msgbox(win);
	    }
	    break;
	case Expose:
	    DebugLog(1, ("Expose count=%d\n", event->xexpose.count));
	    if (event->xexpose.count == 0)
	    {
		gui_tray_draw(win);
	    }
	    break;
	case ButtonPress: /* 按下滑鼠按鍵 */
	    if (event->xbutton.button == Button1)
	    {
		if (gui_msgbox_actived())
		{
		    gui_hide_msgbox(win);
		}
		if (gui_menu_actived())
		{
		    gui_hide_menu();
		}
		else
		{
		    gui_show_menu(win);
		}
	    }
	    break;
	case ClientMessage: /* Client message */
	    if (event->xclient.message_type == xembed_atom)
	    {
		DebugLog(1, ("in tray %d\n", event->xclient.data.l[1]));
	    }
	    else
	    {
		DebugLog(1, ("Unknow Client message -> %d\n", event->xclient.message_type));
	    }
	    break;
	case PropertyNotify:
	    DebugLog(1, ("PropertyNotify\n"));
	    break;
	case DestroyNotify:
	    DebugLog(1, ("DestroyNotify\n"));
	    break;
	default:
	    DebugLog(1, ("tray win event %d\n", event->type));
    }
}
예제 #24
0
int cbDebuggerPlugin::RunNixConsole(wxString &consoleTty)
{
    consoleTty = wxEmptyString;
#ifndef __WXMSW__
    // Start a terminal and put the shell to sleep with -e sleep 80000.
    // Fetch the terminal's tty, so we can tell the debugger what TTY to use,
    // thus redirecting program's stdin/stdout/stderr to the terminal.

    wxString cmd;
    int consolePid = 0;
    // Use the terminal specified by the user in the Settings -> Environment.
    wxString term = Manager::Get()->GetConfigManager(_T("app"))->Read(_T("/console_terminal"), DEFAULT_CONSOLE_TERM);

    term.Replace(_T("$TITLE"), wxString(wxT("'"))+_("Program Console")+wxT("'"));
    cmd << term << _T(" ");

    const wxString &sleepCommand = MakeSleepCommand();
    cmd << sleepCommand;

    Manager::Get()->GetMacrosManager()->ReplaceEnvVars(cmd);

    // The lifetime of wxProcess objects is very uncertain, so we are using a shared pointer to
    // prevent us accessing deleted objects.
    cb::shared_ptr<ConsoleProcessTerminationInfo> processInfo(new ConsoleProcessTerminationInfo);
    ConsoleProcess *process = new ConsoleProcess(processInfo);
    consolePid = wxExecute(cmd, wxEXEC_ASYNC, process);
    if (consolePid <= 0)
        return -1;

    // Try to find the TTY. We're using a loop, because some slow machines might make the check fail due
    // to a slow starting terminal.
    for (int ii = 0; ii < 100; ++ii)
    {
        // First, wait for the terminal to settle down, else PS won't see the sleep task
        Manager::Yield();
        ::wxMilliSleep(200);

        // Try to detect if the terminal command is present or its parameters are valid.
        if (processInfo->FailedToStart() /*&& ii > 0*/)
        {
            Log(F(wxT("Failed to execute terminal command: '%s' (exit code: %d)"),
                  cmd.wx_str(), processInfo->status), Logger::error);
            break;
        }

        // Try to find tty path and pid for the sleep command we've just executed.
        const ConsoleInfo &info = GetConsoleTty(consolePid);

        // If there is no sleep command yet, do another iteration after a small delay.
        if (!info.IsValid())
            continue;

        // Try to find if the console window is still alive. Newer terminals like gnome-terminal
        // try to be easier on resources and use a shared server process. For these terminals the
        // spawned terminal process exits immediately, but the sleep command is still executed.
        // If we detect such case we will return the PID for the sleep command instead of the PID
        // for the terminal.
        if (kill(consolePid, 0) == -1 && errno == ESRCH) {
            DebugLog(F(wxT("Using sleep command's PID as console PID %d, TTY %s"),
                       info.sleepPID, info.ttyPath.wx_str()));
            consoleTty = info.ttyPath;
            return info.sleepPID;
        }
        else
        {
            DebugLog(F(wxT("Using terminal's PID as console PID %d, TTY %s"), info.sleepPID, info.ttyPath.wx_str()));
            consoleTty = info.ttyPath;
            return consolePid;
        }
    }
    // failed to find the console tty
    if (consolePid != 0)
        ::wxKill(consolePid);
#endif // !__WWXMSW__
    return -1;
}
void LobbyReceiveHandler::sessionIn(const ConnectInfo* connectInfo)
{
    DebugLog("LobbyReceiveHandler::sessionIn");
}
예제 #26
0
int CEncryptedDatagramSocket::DecryptReceivedClient(BYTE* pbyBufIn, int nBufLen, BYTE** ppbyBufOut, uint32 dwIP, uint32* nReceiverVerifyKey, uint32* nSenderVerifyKey) const{
	int nResult = nBufLen;
	*ppbyBufOut = pbyBufIn;
	
	if (nReceiverVerifyKey == NULL || nSenderVerifyKey == NULL){
		ASSERT( false );
		return nResult;
	}
	
	*nReceiverVerifyKey = 0;
	*nSenderVerifyKey = 0;

	if (nResult <= CRYPT_HEADER_WITHOUTPADDING /*|| !thePrefs.IsClientCryptLayerSupported()*/)
		return nResult;	

	switch (pbyBufIn[0]){
		case OP_EMULEPROT:
		case OP_KADEMLIAPACKEDPROT:
		case OP_KADEMLIAHEADER:
		case OP_UDPRESERVEDPROT1:
		case OP_UDPRESERVEDPROT2:
		case OP_PACKEDPROT:
			return nResult; // no encrypted packet (see description on top)
	}

	// might be an encrypted packet, try to decrypt
	RC4_Key_Struct keyReceiveKey;
	uint32 dwValue = 0;
	// check the marker bit which type this packet could be and which key to test first, this is only an indicator since old clients have it set random
	// see the header for marker bits explanation
	byte byCurrentTry = ((pbyBufIn[0] & 0x03) == 3) ? 1 : (pbyBufIn[0] & 0x03); 
	byte byTries;
	if (Kademlia::CKademlia::GetPrefs() == NULL) {
		// if kad never run, no point in checking anything except for ed2k encryption
		byTries = 1;
		byCurrentTry = 1;
	}
	else
		byTries = 3;
	bool bKadRecvKeyUsed = false;
	bool bKad = false;
	do{
		byTries--;
		MD5Sum md5;
		if (byCurrentTry == 0) {
			// kad packet with NodeID as key
			bKad = true;
			bKadRecvKeyUsed = false;
			if (Kademlia::CKademlia::GetPrefs()) {
				uchar achKeyData[18];
				memcpy(achKeyData, Kademlia::CKademlia::GetPrefs()->GetKadID().GetData(), 16);
				memcpy(achKeyData + 16, pbyBufIn + 1, 2); // random key part sent from remote client
				md5.Calculate(achKeyData, sizeof(achKeyData));
			}
		}
		else if (byCurrentTry == 1) {
			// ed2k packet
			bKad = false;
			bKadRecvKeyUsed = false;
			uchar achKeyData[23];
			md4cpy(achKeyData, thePrefs.GetUserHash());
			achKeyData[20] = MAGICVALUE_UDP;
			memcpy(achKeyData + 16, &dwIP, 4);
			memcpy(achKeyData + 21, pbyBufIn + 1, 2); // random key part sent from remote client
			md5.Calculate(achKeyData, sizeof(achKeyData));
		}
		else if (byCurrentTry == 2) {
			// kad packet with ReceiverKey as key
			bKad = true;
			bKadRecvKeyUsed = true;
			if (Kademlia::CKademlia::GetPrefs()) {
				uchar achKeyData[6];
				PokeUInt32(achKeyData, Kademlia::CPrefs::GetUDPVerifyKey(dwIP));
				memcpy(achKeyData + 4, pbyBufIn + 1, 2); // random key part sent from remote client
				md5.Calculate(achKeyData, sizeof(achKeyData));
			}
		}
		else
			ASSERT( false );

		RC4CreateKey(md5.GetRawHash(), 16, &keyReceiveKey, true);
		RC4Crypt(pbyBufIn + 3, (uchar*)&dwValue, sizeof(dwValue), &keyReceiveKey);
		byCurrentTry = (byCurrentTry + 1) % 3;
	} while (dwValue != MAGICVALUE_UDP_SYNC_CLIENT && byTries > 0); // try to decrypt as ed2k as well as kad packet if needed (max 3 rounds)
	
	if (dwValue == MAGICVALUE_UDP_SYNC_CLIENT){
		// yup this is an encrypted packet
		// debugoutput notices
		// the following cases are "allowed" but shouldn't happen given that there is only our implementation yet
		if (bKad && (pbyBufIn[0] & 0x01) != 0)
			DebugLog(_T("Received obfuscated UDP packet from clientIP: %s with wrong key marker bits (kad packet, ed2k bit)"), ipstr(dwIP));
		else if (bKad && !bKadRecvKeyUsed && (pbyBufIn[0] & 0x02) != 0)
			DebugLog(_T("Received obfuscated UDP packet from clientIP: %s with wrong key marker bits (kad packet, nodeid key, recvkey bit)"), ipstr(dwIP));
		else if (bKad && bKadRecvKeyUsed && (pbyBufIn[0] & 0x02) == 0)
			DebugLog(_T("Received obfuscated UDP packet from clientIP: %s with wrong key marker bits (kad packet, recvkey key, nodeid bit)"), ipstr(dwIP));

		uint8 byPadLen;
		RC4Crypt(pbyBufIn + 7, (uchar*)&byPadLen, 1, &keyReceiveKey);
		nResult -= CRYPT_HEADER_WITHOUTPADDING;
		if (nResult <= byPadLen){
			DebugLogError(_T("Invalid obfuscated UDP packet from clientIP: %s, Paddingsize (%u) larger than received bytes"), ipstr(dwIP), byPadLen);
			return nBufLen; // pass through, let the Receivefunction do the errorhandling on this junk
		}
		if (byPadLen > 0)
			RC4Crypt(NULL, NULL, byPadLen, &keyReceiveKey);
		nResult -= byPadLen;

		if (bKad){
			if (nResult <= 8){
				DebugLogError(_T("Obfuscated Kad packet with mismatching size (verify keys missing) received from clientIP: %s"), ipstr(dwIP));
				return nBufLen; // pass through, let the Receivefunction do the errorhandling on this junk;
			}
			// read the verify keys
			RC4Crypt(pbyBufIn + CRYPT_HEADER_WITHOUTPADDING + byPadLen, (uchar*)nReceiverVerifyKey, 4, &keyReceiveKey);
			RC4Crypt(pbyBufIn + CRYPT_HEADER_WITHOUTPADDING + byPadLen + 4, (uchar*)nSenderVerifyKey, 4, &keyReceiveKey);
			nResult -= 8;
		}
		*ppbyBufOut = pbyBufIn + (nBufLen - nResult);
		RC4Crypt((uchar*)*ppbyBufOut, (uchar*)*ppbyBufOut, nResult, &keyReceiveKey);
		//Xman
		// Maella -Accurate measure of bandwidth: eDonkey data + control, network adapter-
		/*
		theStats.AddDownDataOverheadCrypt(nBufLen - nResult);
		*/
		theApp.pBandWidthControl->AddeMuleInObfuscation(nBufLen - nResult);
		//Xman end
		//DEBUG_ONLY( DebugLog(_T("Received obfuscated UDP packet from clientIP: %s, Key: %s, RKey: %u, SKey: %u"), ipstr(dwIP), bKad ? (bKadRecvKeyUsed ? _T("ReceiverKey") : _T("NodeID")) : _T("UserHash")
		//	, nReceiverVerifyKey != 0 ? *nReceiverVerifyKey : 0, nSenderVerifyKey != 0 ? *nSenderVerifyKey : 0) );
		return nResult; // done
	}
	else{
		DebugLogWarning(_T("Obfuscated packet expected but magicvalue mismatch on UDP packet from clientIP: %s, Possible RecvKey: %u"), ipstr(dwIP), Kademlia::CPrefs::GetUDPVerifyKey(dwIP));
		return nBufLen; // pass through, let the Receivefunction do the errorhandling on this junk
	}
}
예제 #27
0
void CClientList::Process()
{
	///////////////////////////////////////////////////////////////////////////
	// Cleanup banned client list
	//
	const uint32 cur_tick = ::GetTickCount();
	if (m_dwLastBannCleanUp + BAN_CLEANUP_TIME < cur_tick)
	{
		m_dwLastBannCleanUp = cur_tick;
		
		POSITION pos = m_bannedList.GetStartPosition();
		uint32 nKey;
		uint32 dwBantime;
		while (pos != NULL)
		{
			m_bannedList.GetNextAssoc( pos, nKey, dwBantime );
			if (dwBantime + CLIENTBANTIME < cur_tick )
				RemoveBannedClient(nKey);
		}
	}

	///////////////////////////////////////////////////////////////////////////
	// Cleanup tracked client list
	//
	if (m_dwLastTrackedCleanUp + TRACKED_CLEANUP_TIME < cur_tick)
	{
		m_dwLastTrackedCleanUp = cur_tick;
		if (thePrefs.GetLogBannedClients())
			AddDebugLogLine(false, _T("Cleaning up TrackedClientList, %i clients on List..."), m_trackedClientsList.GetCount());
		POSITION pos = m_trackedClientsList.GetStartPosition();
		uint32 nKey;
		CDeletedClient* pResult;
		while (pos != NULL)
		{
			m_trackedClientsList.GetNextAssoc( pos, nKey, pResult );
			if (pResult->m_dwInserted + KEEPTRACK_TIME < cur_tick ){
				m_trackedClientsList.RemoveKey(nKey);
				delete pResult;
			}
		}
		if (thePrefs.GetLogBannedClients())
			AddDebugLogLine(false, _T("...done, %i clients left on list"), m_trackedClientsList.GetCount());
	}

	///////////////////////////////////////////////////////////////////////////
	// Process Kad client list
	//
	//We need to try to connect to the clients in m_KadList
	//If connected, remove them from the list and send a message back to Kad so we can send a ACK.
	//If we don't connect, we need to remove the client..
	//The sockets timeout should delete this object.
	//MORPH START - Removed by Stulle, Optimize Process Kad client list [WiZaRd]
	/*
	POSITION pos1, pos2;
	*/
	//MORPH END   - Removed by Stulle, Optimize Process Kad client list [WiZaRd]

	// buddy is just a flag that is used to make sure we are still connected or connecting to a buddy.
	buddyState buddy = Disconnected;

	//MORPH START - Changed by Stulle, Optimize Process Kad client list [WiZaRd]
	/*
	for (pos1 = m_KadList.GetHeadPosition(); (pos2 = pos1) != NULL; )
	{
		m_KadList.GetNext(pos1);
		CUpDownClient* cur_client =	m_KadList.GetAt(pos2);
	*/
	for (POSITION pos = m_KadList.GetHeadPosition(); pos != NULL; )
	{
		POSITION posLast = pos;
		CUpDownClient* cur_client =     m_KadList.GetNext(pos);
	//MORPH END   - Changed by Stulle, Optimize Process Kad client list [WiZaRd]
		if( !Kademlia::CKademlia::IsRunning() )
		{
			//Clear out this list if we stop running Kad.
			//Setting the Kad state to KS_NONE causes it to be removed in the switch below.
			cur_client->SetKadState(KS_NONE);
		}
		switch(cur_client->GetKadState())
		{
			case KS_QUEUED_FWCHECK:
			case KS_QUEUED_FWCHECK_UDP:
				//Another client asked us to try to connect to them to check their firewalled status.
				cur_client->TryToConnect(true, true);
				break;
			case KS_CONNECTING_FWCHECK:
				//Ignore this state as we are just waiting for results.
				break;
			case KS_FWCHECK_UDP:
			case KS_CONNECTING_FWCHECK_UDP:
				// we want a UDP firewallcheck from this client and are just waiting to get connected to send the request
				break;
			case KS_CONNECTED_FWCHECK:
				//We successfully connected to the client.
				//We now send a ack to let them know.
				if (cur_client->GetKadVersion() >= KADEMLIA_VERSION7_49a){
					// the result is now sent per TCP instead of UDP, because this will fail if our intern UDP port is unreachable.
					// But we want the TCP testresult regardless if UDP is firewalled, the new UDP state and test takes care of the rest					
					ASSERT( cur_client->socket != NULL && cur_client->socket->IsConnected() );
					if (thePrefs.GetDebugClientTCPLevel() > 0)
						DebugSend("OP_KAD_FWTCPCHECK_ACK", cur_client);
					Packet* pPacket = new Packet(OP_KAD_FWTCPCHECK_ACK, 0, OP_EMULEPROT);
					if (!cur_client->SafeConnectAndSendPacket(pPacket))
						cur_client = NULL;
				}
				else {
					if (thePrefs.GetDebugClientKadUDPLevel() > 0)
						DebugSend("KADEMLIA_FIREWALLED_ACK_RES", cur_client->GetIP(), cur_client->GetKadPort());
					Kademlia::CKademlia::GetUDPListener()->SendNullPacket(KADEMLIA_FIREWALLED_ACK_RES, ntohl(cur_client->GetIP()), cur_client->GetKadPort(), 0, NULL);
				}
				//We are done with this client. Set Kad status to KS_NONE and it will be removed in the next cycle.
				if (cur_client != NULL)
					cur_client->SetKadState(KS_NONE);
				break;

			case KS_INCOMING_BUDDY:
				//A firewalled client wants us to be his buddy.
				//If we already have a buddy, we set Kad state to KS_NONE and it's removed in the next cycle.
				//If not, this client will change to KS_CONNECTED_BUDDY when it connects.
				if( m_nBuddyStatus == Connected )
					cur_client->SetKadState(KS_NONE);
				break;

			case KS_QUEUED_BUDDY:
				//We are firewalled and want to request this client to be a buddy.
				//But first we check to make sure we are not already trying another client.
				//If we are not already trying. We try to connect to this client.
				//If we are already connected to a buddy, we set this client to KS_NONE and it's removed next cycle.
				//If we are trying to connect to a buddy, we just ignore as the one we are trying may fail and we can then try this one.
				if( m_nBuddyStatus == Disconnected )
				{
					buddy = Connecting;
					m_nBuddyStatus = Connecting;
					cur_client->SetKadState(KS_CONNECTING_BUDDY);
					cur_client->TryToConnect(true, true);
					theApp.emuledlg->serverwnd->UpdateMyInfo();
				}
				else if( m_nBuddyStatus == Connected )
					cur_client->SetKadState(KS_NONE);
				break;

			case KS_CONNECTING_BUDDY:
				//We are trying to connect to this client.
				//Although it should NOT happen, we make sure we are not already connected to a buddy.
				//If we are we set to KS_NONE and it's removed next cycle.
				//But if we are not already connected, make sure we set the flag to connecting so we know 
				//things are working correctly.
				if( m_nBuddyStatus == Connected )
					cur_client->SetKadState(KS_NONE);
				else
				{
					ASSERT( m_nBuddyStatus == Connecting );
					buddy = Connecting;
				}
				break;

			case KS_CONNECTED_BUDDY:
				//A potential connected buddy client wanting to me in the Kad network
				//We set our flag to connected to make sure things are still working correctly.
				buddy = Connected;
				
				//If m_nBuddyStatus is not connected already, we set this client as our buddy!
				if( m_nBuddyStatus != Connected )
				{
					m_pBuddy = cur_client;
					m_nBuddyStatus = Connected;
					theApp.emuledlg->serverwnd->UpdateMyInfo();
				}
				if( m_pBuddy == cur_client && theApp.IsFirewalled() && cur_client->SendBuddyPingPong() )
				{
					if (thePrefs.GetDebugClientTCPLevel() > 0)
						DebugSend("OP__BuddyPing", cur_client);
					Packet* buddyPing = new Packet(OP_BUDDYPING, 0, OP_EMULEPROT);
					theStats.AddUpDataOverheadOther(buddyPing->size);
					VERIFY( cur_client->SendPacket(buddyPing, true, true) );
					cur_client->SetLastBuddyPingPongTime();
				}
				break;

			default:
				//MORPH START - Changed by Stulle, Optimize Process Kad client list [WiZaRd]
				/*
				RemoveFromKadList(cur_client);
				*/
				//removed function overhead
				if(cur_client == m_pBuddy)
				{
					//MORPH START - Added by Stulle, Fix for setting buddy state on removing buddy [WiZaRd]
					buddy = Disconnected;
					m_nBuddyStatus = Disconnected;
					//MORPH END   - Added by Stulle, Fix for setting buddy state on removing buddy [WiZaRd]
					m_pBuddy = NULL;
					theApp.emuledlg->serverwnd->UpdateMyInfo();
				}
				m_KadList.RemoveAt(posLast);
				//MORPH END   - Changed by Stulle, Optimize Process Kad client list [WiZaRd]
		}
	}
	
	//We either never had a buddy, or lost our buddy..
	if( buddy == Disconnected )
	{
		if( m_nBuddyStatus != Disconnected || m_pBuddy )
		{
			if( Kademlia::CKademlia::IsRunning() && theApp.IsFirewalled() && Kademlia::CUDPFirewallTester::IsFirewalledUDP(true))
			{
				//We are a lowID client and we just lost our buddy.
				//Go ahead and instantly try to find a new buddy.
				Kademlia::CKademlia::GetPrefs()->SetFindBuddy();
			}
			m_pBuddy = NULL;
			m_nBuddyStatus = Disconnected;
			theApp.emuledlg->serverwnd->UpdateMyInfo();
		}
	}

	if ( Kademlia::CKademlia::IsConnected() )
	{
		//we only need a buddy if direct callback is not available
		if( Kademlia::CKademlia::IsFirewalled() && Kademlia::CUDPFirewallTester::IsFirewalledUDP(true))
		{
			//TODO 0.49b: Kad buddies won'T work with RequireCrypt, so it is disabled for now but should (and will)
			//be fixed in later version
			// Update: Buddy connections itself support obfuscation properly since 0.49a (this makes it work fine if our buddy uses require crypt)
			// ,however callback requests don't support it yet so we wouldn't be able to answer callback requests with RequireCrypt, protocolchange intended for the next version
			if( m_nBuddyStatus == Disconnected && Kademlia::CKademlia::GetPrefs()->GetFindBuddy() && !thePrefs.IsClientCryptLayerRequired())
			{
				DEBUG_ONLY( DebugLog(_T("Starting Buddysearch")) );
				//We are a firewalled client with no buddy. We have also waited a set time 
				//to try to avoid a false firewalled status.. So lets look for a buddy..
				if( !Kademlia::CSearchManager::PrepareLookup(Kademlia::CSearch::FINDBUDDY, true, Kademlia::CUInt128(true).Xor(Kademlia::CKademlia::GetPrefs()->GetKadID())) )
				{
					//This search ID was already going. Most likely reason is that
					//we found and lost our buddy very quickly and the last search hadn't
					//had time to be removed yet. Go ahead and set this to happen again
					//next time around.
					Kademlia::CKademlia::GetPrefs()->SetFindBuddy();
				}
			}
		}
		else
		{
			if( m_pBuddy )
			{
				//Lets make sure that if we have a buddy, they are firewalled!
				//If they are also not firewalled, then someone must have fixed their firewall or stopped saturating their line.. 
				//We just set the state of this buddy to KS_NONE and things will be cleared up with the next cycle.
				if( !m_pBuddy->HasLowID() )
					m_pBuddy->SetKadState(KS_NONE);
			}
		}
	}
	else
	{
		if( m_pBuddy )
		{
			//We are not connected anymore. Just set this buddy to KS_NONE and things will be cleared out on next cycle.
			m_pBuddy->SetKadState(KS_NONE);
		}
	}

	///////////////////////////////////////////////////////////////////////////
	// Cleanup client list
	//
	CleanUpClientList();

	///////////////////////////////////////////////////////////////////////////
	// Process Direct Callbacks for Timeouts
	//
	ProcessConnectingClientsList();
}
예제 #28
0
// |----------------------------------------------------------------------------|
// |							  Copy Constructor								|
// |----------------------------------------------------------------------------|
ParticleSystem::ParticleSystem(const ParticleSystem&) {
    DebugLog ("ParticleSystem: object copied.");
}
예제 #29
0
void CBSlideBar::onButtonClick(CBView* target, int index)
{
	DebugLog("click [%d] button in CBSlideBar\n",index);
	if(m_buttonClick)
		m_buttonClick->invoke(target,index);
}
예제 #30
0
	void CMMI::Communication(void)
	{
		COMM_BUFFER mmiToSeq;

		if(FALSE == m_kamelas.Recv((PBYTE)&mmiToSeq))
			return;


		switch(mmiToSeq.nCmd)
		{
		case CMD_RD_PKG_DATA:
			{
				int nSize  = sizeof(double) * MAX_PKG_DATA;
				double* pOrigin = &g_nv.m_pNVdata->dbPkgData[0];
				double* pTarget = &mmiToSeq.buffer.pkgData.dData[0];
				memcpy(pTarget, pOrigin, nSize);
			}
			break;

		case CMD_WR_PKG_DATA:
			{
				int nStart = mmiToSeq.buffer.pkgData.nStart;
				int nEnd   = mmiToSeq.buffer.pkgData.nEnd;
				int nSize  = GetSize(nStart, nEnd, sizeof(double), MAX_PKG_DATA);

				if(nSize < 0)
				{
					DebugLog(L"CMD_WR_PKG_DATA fail : range err!!");
					break;
				}

				double* pOrigin = &mmiToSeq.buffer.pkgData.dData[nStart];
				double* pTarget = &g_nv.m_pNVdata->dbPkgData[nStart];
				memcpy(pTarget, pOrigin, nSize);

			}
			break;

		case CMD_RD_NDM:
			{
				int nSize  = sizeof(int) * MAX_NDM_DATA;
				int* pOrigin = &g_nv.m_pNVdata->nDmData[0];
				int* pTarget = &mmiToSeq.buffer.nDm.nData[0];
				memcpy(pTarget, pOrigin, nSize);
			}
			break;

		case CMD_WR_NDM:
			{
				int nStart = mmiToSeq.buffer.nDm.nStart;
				int nEnd   = mmiToSeq.buffer.nDm.nEnd;
				int nSize  = GetSize(nStart, nEnd, sizeof(int), MAX_NDM_DATA);

				if(nSize < 0)
				{
					DebugLog(L"CMD_WR_NDM fail : range err!!");
					break;
				}

				int* pOrigin = &mmiToSeq.buffer.nDm.nData[nStart];
				int* pTarget = &g_nv.m_pNVdata->nDmData[nStart];
				memcpy(pTarget, pOrigin, nSize);
			}
			break;

		case CMD_RD_DDM:
			{
				int nSize  = sizeof(double) * MAX_DDM_DATA;
				double* pOrigin = &g_nv.m_pNVdata->dbDmData[0];
				double* pTarget = &mmiToSeq.buffer.dDm.dData[0];
				memcpy(pTarget, pOrigin, nSize);
			}
			break;

		case CMD_WR_DDM:
			{
				int nStart = mmiToSeq.buffer.dDm.nStart;
				int nEnd   = mmiToSeq.buffer.dDm.nEnd;
				int nSize  = GetSize(nStart, nEnd, sizeof(double), MAX_DDM_DATA);

				if(nSize < 0)
				{
					DebugLog(L"CMD_WR_DDM fail : range err!!");
					break;
				}

				double* pOrigin = &mmiToSeq.buffer.dDm.dData[nStart];
				double* pTarget = &g_nv.m_pNVdata->dbDmData[nStart];
				memcpy(pTarget, pOrigin, nSize);
			}
			break;


		case CMD_RD_USESKIP:
			{
				int nSize  = sizeof(int) * MAX_USE_SKIP_DATA;
				int* pOrigin = &g_nv.m_pNVdata->bUseSkipData[0];
				int* pTarget = &mmiToSeq.buffer.useSkip.nData[0];
				memcpy(pTarget, pOrigin, nSize);
			}
			break;

		case CMD_WR_USESKIP:
			{
				int nStart = mmiToSeq.buffer.useSkip.nStart;
				int nEnd   = mmiToSeq.buffer.useSkip.nEnd;
				int nSize  = GetSize(nStart, nEnd, sizeof(int), MAX_USE_SKIP_DATA);

				if(nSize < 0)
				{
					DebugLog(L"CMD_WR_USESKIP fail : range err!!");
					break;
				}

				int* pOrigin = &mmiToSeq.buffer.useSkip.nData[nStart];
				int* pTarget = &g_nv.m_pNVdata->bUseSkipData[nStart];
				memcpy(pTarget, pOrigin, nSize);
			}
			break;


		case CMD_RD_IO:
			{
				PWORD pTarget, pOrigin;
				int nSize;

				nSize   = INPUTCH_CNT * sizeof(WORD);
				pTarget = &mmiToSeq.buffer.io.inCH[0];
				pOrigin = &g_input.m_ch[0];
				memcpy(pTarget, pOrigin, nSize);


				nSize   = OUTPUTCH_CNT * sizeof(WORD);
				pTarget = &mmiToSeq.buffer.io.outCH[0];
				pOrigin = &g_output.m_ch[0];
				memcpy(pTarget, pOrigin, nSize);	
			}
			break;

		case CMD_WR_IO:
			{
				if(!g_opr.bStop || g_opr.bPaused)
					break;

				int nStart = mmiToSeq.buffer.io.nStart;
				int nEnd   = mmiToSeq.buffer.io.nEnd;
				int nSize  = GetSize(nStart, nEnd, sizeof(WORD), OUTPUTCH_CNT);

				if(nSize < 0)
				{
					DebugLog(L"CMD_WR_IO fail : range err!!");
					break;
				}

				WORD* pOrigin = &mmiToSeq.buffer.io.outCH[nStart];
				WORD* pTarget = &g_output.m_ch[nStart];
				memcpy(pTarget, pOrigin, nSize);
			}
			break;

		case CMD_RD_ERROR:
			{
				UINT nSize = sizeof(UINT) * 10;
				UINT *pTarget = &mmiToSeq.buffer.nErr[0];
				UINT *pOrigin = g_err.GetAddr();
				memcpy(pTarget, pOrigin, nSize);
			}
			break;


		case CMD_RD_MT_STATUS:
			{
				int nMtNo = mmiToSeq.buffer.mtData.nMtNo; 
				if(!Between(nMtNo, 0, 19))
					break;

				mmiToSeq.buffer.mtData.state.bServoOn  = g_mt[nMtNo].m_state.bServoOn;   
				mmiToSeq.buffer.mtData.state.bCCw      = g_mt[nMtNo].m_state.bLimitCCw;
				mmiToSeq.buffer.mtData.state.bCw       = g_mt[nMtNo].m_state.bLimitCw;
				mmiToSeq.buffer.mtData.state.bOrg      = g_mt[nMtNo].m_state.bOrg;
				mmiToSeq.buffer.mtData.state.bHome     = g_mt[nMtNo].IsHome();
				mmiToSeq.buffer.mtData.state.bDriving  = g_mt[nMtNo].m_state.bDriving;
				mmiToSeq.buffer.mtData.state.bPaused   = g_mt[nMtNo].IsPaused();
				mmiToSeq.buffer.mtData.state.dRealCnt  = g_mt[nMtNo].m_state.nRealCnt;
				mmiToSeq.buffer.mtData.state.bAlarm    = g_mt[nMtNo].m_state.bAlarm;
				mmiToSeq.buffer.mtData.state.nCurIndex = g_mt[nMtNo].m_nCurIndex;
			}
			break;

		case CMD_WR_MT_CMD:
			{
				
				int nMtNo = mmiToSeq.buffer.mtData.nMtNo; 
				if(!Between(nMtNo, 0, 19))
					break;

				int nCmd   = mmiToSeq.buffer.mtData.control.nControlType;
				int nIndex = mmiToSeq.buffer.mtData.control.nCmdIndexNo;
				int nDir   = mmiToSeq.buffer.mtData.control.nDir;
				int nPulse = (int)(mmiToSeq.buffer.mtData.control.dPulse); 
				int nJogVel= g_nv.NDm(jogSpeed); //g_mt[nMtNo].m_config.nFastHomeSpeed;


				switch(nCmd)
				{
				case MTCMD_SERVO_ON:
					if(!g_opr.bStop)
						break;
					g_mt[nMtNo].ServoOn();
					break;

				case MTCMD_SERVO_OFF:
					if(!g_opr.bStop)
						break;
					g_mt[nMtNo].ServoOff();
					break;

				case MTCMD_INDEX_MOVE:
					if(g_nv.NDm(doorOpen))
					{
						g_err.ChkDoor();
						break;
					}

					if(!g_opr.bStop || g_opr.bEmg || g_opr.bPaused || g_allHome.m_bStartAll || AOn(iMarkProg))
						break;

// 					if(!g_MtSafety.CanMove(nMtNo, nIndex))
// 						break;

					if(!g_err.ChkMtSafety(nMtNo, nIndex))
						break;

					// Rear Stage 동기화 Move
					if (MT_REAR_STAGE == nMtNo)
					{
						int nBasePos = g_mt[MT_REAR_STAGE].m_table.nPos[nIndex];
						int nTargetPos = nBasePos - (int)(g_nv.Dm(rearStageSyncOffset) * 1000);

						g_mt[MT_REAR_STAGE].PMove(nIndex, nTargetPos);
						break;
					}

					g_mt[nMtNo].Move(nIndex);
					break;

				case MTCMD_JOG_MOVE:
					if(g_nv.NDm(doorOpen))
					{
						g_err.ChkDoor();
						break;
					}

					if(!g_opr.bStop || g_opr.bEmg || g_opr.bPaused || g_allHome.m_bStartAll || AOn(iMarkProg))
						break;

// 					if(!g_MtSafety.CanMove(nMtNo))
// 						break;

					if(g_mt[nMtNo].m_nCmdIndex < MTINDEX_WAIT)
					{
						g_mt[nMtNo].m_nNextIndex = g_mt[nMtNo].m_nCmdIndex;
						g_mt[nMtNo].m_nCmdIndex  = g_mt[nMtNo].m_nCurIndex = MTINDEX_WAIT;
					}

					if(nDir)
						g_mt[nMtNo].RMove(200000, nJogVel); //1회 최대 이동량은 200mm
					else
						g_mt[nMtNo].RMove(-200000, nJogVel);
					break;

				case MTCMD_JOG_STOP:
					g_mt[nMtNo].Stop(TRUE);
					break;

				case MTCMD_R_MOVE:
					if(g_nv.NDm(doorOpen))
					{
						g_err.ChkDoor();
						break;
					}

					if(!g_opr.bStop || g_opr.bEmg || g_opr.bPaused || g_allHome.m_bStartAll)
						break;

// 					if(!g_MtSafety.CanMove(nMtNo))
// 						break;

					if(g_mt[nMtNo].m_nCmdIndex < MTINDEX_WAIT)
					{
						g_mt[nMtNo].m_nNextIndex = g_mt[nMtNo].m_nCmdIndex;
						g_mt[nMtNo].m_nCmdIndex  = g_mt[nMtNo].m_nCurIndex = MTINDEX_WAIT;
					}

					if(nDir)
						g_mt[nMtNo].RMove(nPulse, nJogVel);
					else
						g_mt[nMtNo].RMove(nPulse * (-1), nJogVel);
					break;

				case MTCMD_A_MOVE:
					{
						if(g_nv.NDm(doorOpen))
						{
							g_err.ChkDoor();
							break;
						}

						if(!g_opr.bStop || g_opr.bEmg || g_opr.bPaused || g_allHome.m_bStartAll)
							break;

// 						if(!g_MtSafety.CanMove(nMtNo))
// 							break;

						if(g_mt[nMtNo].m_nCmdIndex < MTINDEX_WAIT)
						{
							g_mt[nMtNo].m_nNextIndex = g_mt[nMtNo].m_nCmdIndex;
							g_mt[nMtNo].m_nCmdIndex  = g_mt[nMtNo].m_nCurIndex = MTINDEX_WAIT;
						}

						int nAMovePos = nPulse - g_mt[nMtNo].m_state.nCmdCnt;
						g_mt[nMtNo].RMove(nAMovePos);
					}
					break;

				case MTCMD_ALL_HOME:
					break;

				case MTCMD_HOME:
					if(g_nv.NDm(doorOpen))
					{
						g_err.ChkDoor();
						break;
					}

					if(!g_opr.bStop || g_opr.bEmg || g_opr.bPaused || g_allHome.m_bStartAll)
						break;

// 					if(!g_MtSafety.CanMove(nMtNo))
// 						break;

					g_mt[nMtNo].CancelHomeSearch();
					g_mt[nMtNo].StartHomeSearch();
					break;

				case MTCMD_RESET:
					g_mt[nMtNo].AlarmClear();
					break;

				case MTCMD_STOP:
					g_mt[nMtNo].Stop(FALSE);
					break;
				}
			}
			break;

		case CMD_RD_MTTABLE:
			{
				int nMtNo = mmiToSeq.buffer.mtData.nMtNo; 
				if(!Between(nMtNo, 0, 19))
					break;

				for(int nIndex = 0; nIndex < MAX_MTARRAY; nIndex++)
				{
					mmiToSeq.buffer.mtData.table.dPos[nIndex]   = g_mt[nMtNo].m_table.nPos[nIndex];
					mmiToSeq.buffer.mtData.table.dSpeed[nIndex] = g_mt[nMtNo].m_table.nSpeed[nIndex];
				}
			}
			break;

		case CMD_WR_MTTABLE:
			{
				
				int nMtNo = mmiToSeq.buffer.mtData.nMtNo; 
				if(!Between(nMtNo, 0, 19))
					break;

				for(int nIndex = 0; nIndex < MAX_MTARRAY; nIndex ++)
				{
					g_mt[nMtNo].m_table.nPos[nIndex]   = (int)(mmiToSeq.buffer.mtData.table.dPos[nIndex]);
					g_mt[nMtNo].m_table.nSpeed[nIndex] = (int)(mmiToSeq.buffer.mtData.table.dSpeed[nIndex]);

					if(g_mt[nMtNo].m_config.nMaxSpeed < g_mt[nMtNo].m_table.nSpeed[nIndex])
					{
						g_mt[nMtNo].m_table.nSpeed[nIndex] = g_mt[nMtNo].m_config.nMaxSpeed;
					}
				}

				g_nv.WriteMtTable(nMtNo, g_mt[nMtNo].m_table);
			}
			break;

		case CMD_WR_PRSVI:
			//			
			break;

		case CMD_RD_MARK_COORD_F:
			//
			break;

		case CMD_RD_MARK_COORD_R:
			//
			break;

		case CMD_WR_ID_SEL_MAP_DATA:
			{
				// 초기화 Data(0) 검출..
				g_LdMz.m_bSelMapDataInitErr = TRUE;
				g_LdMz.m_bSelMapDataErr = FALSE;

				int nMaxCnt =  (int)(g_nv.PkgData(unitXcnt) * g_nv.PkgData(unitYcnt) * g_nv.PkgData(blockCount));

				for (int i = 0; i < 300; i++)
				{
					if(i < nMaxCnt)
					{
						g_LdMz.m_Info.nSelectMapData[i] = mmiToSeq.buffer.nIdSelMapData[i];

						// Data 오류 검출(1 이상의 값은 쓰레기 Data)
						if(1 < g_LdMz.m_Info.nSelectMapData[i])
							g_LdMz.m_bSelMapDataErr = TRUE;
						if(1 == g_LdMz.m_Info.nSelectMapData[i])
							g_LdMz.m_bSelMapDataInitErr = FALSE;
					}
					else
					{
						g_LdMz.m_Info.nSelectMapData[i] = 0;
					}
				}
			}
			break;

		case CMD_RD_MK_SEL_MAP_DATA:
			{
				int nMaxCnt = (int)(g_nv.PkgData(unitXcnt) * g_nv.PkgData(unitYcnt) * g_nv.PkgData(blockCount));

				BOOL bErr = FALSE;

				for(int nCnt = 0; nCnt < 300; nCnt++)
				{
					if(nCnt < nMaxCnt)
					{
						if(1 == g_nv.PkgData(useSkipSelectMap))
							mmiToSeq.buffer.nMkSelMapData[nCnt] = g_mkSelMap.nData[nCnt];
						else
							mmiToSeq.buffer.nMkSelMapData[nCnt] = _GOOD_;
						
						if(1 < mmiToSeq.buffer.nMkSelMapData[nCnt])
							bErr = TRUE;
					}
					else
					{
						mmiToSeq.buffer.nMkSelMapData[nCnt] = 0;
					}
				}

				if(bErr)
					g_err.Save(ER_LSR_WRONG_MAP_DATA);
			}
			break;

		case CMD_RD_QC_SEL_MAP_DATA:
			{
				int nMaxCnt = (int)(g_nv.PkgData(unitXcnt) * g_nv.PkgData(unitYcnt) * g_nv.PkgData(blockCount));

				BOOL bErr = FALSE;
				
				for(int nCnt = 0; nCnt < 300; nCnt++)
				{
					if(nCnt < nMaxCnt)
					{
						if(1 == g_nv.PkgData(useSkipSelectMap))
							mmiToSeq.buffer.nQcSelMapData[nCnt] = g_qcSelMap.nData[nCnt];
						else
							mmiToSeq.buffer.nQcSelMapData[nCnt] = _GOOD_;

						if(1 < mmiToSeq.buffer.nQcSelMapData[nCnt])
							bErr = TRUE;
					}
					else
					{
						mmiToSeq.buffer.nQcSelMapData[nCnt] = 0;
					}
				}

				if(bErr)
				{
					g_err.Save(ER_QC_WRONG_MAP_DATA);
				}
			}
			break;
		}

		if(FALSE == m_kamelas.Send((PBYTE)&mmiToSeq))
		{
			DebugLog(L"Kamelas Err : Failed to send data!!");
		}
	}