• Content count

  • Joined

  • Last visited

Community Reputation

254 Neutral

About Anntor

  • Rank
  1. [web] PHP issues

    [quote name='rip-off' timestamp='1302527232' post='4797099'] When you fix your current problem, you should do some research on how to avoid SQL injection. [/quote] In addition to this, please use proper code style too It's hard to read your code. Example needed? [quote name='Zorerk' timestamp='1302521123' post='4797052'] [code] $username="*****"; $PasswordUser=$_POST['PasswordUser']; $Encrypted_password=md5($PasswordUser); [/code] [/quote] Either all lower case or all camel case or the first letter capitalized and all others not and so on. Oh and btw, you said you see nothing (white screen). But what's up with your error file? Was it created? Is something in there? [quote name='Zorerk' timestamp='1302521123' post='4797052'] [code]ini_set('error_log', dirname(__FILE__) . '/error_log.txt'); [/code] [/quote]
  2. RPG Classes

    [quote]Your result for The Fantasy RPG Class Test... [b]The Rune Weaver[/b] 18% Strength, 15% Bloodlust, 30% Intelligence, 35% Spirit, 37% Vitality and 53% Agility! This is a rare mixed class that requires at least three variables to be extremely high.[/quote] Nicely done! Did you do the artwork of each class yourself? They are incredible!
  3. [quote name='Sendo' timestamp='1301310362' post='4791275']...To avoid to have to perform a series calculations on all fleet in movement i devised a method where a flightpath is broken up into overlapping cubes. when a new flightpath is added it just checks the cubes in other flightpaths...[/quote] Your "...just checks..." sounds to complex. If i understand you right, than i would store a fleets path in another way than you described it. Let me explain: ----------------------------- Your space system is divided into cubes (like an octree). A fleet follows a path from A to B and passes different cubes while moving. But at any specific time, it just passes ONE cube. Save this cube in your database, along with the time when it enters this cube and when it leaves this cube, which both depends on the flight path. You can precompute the time, when a fleet leaves its current cube (or "sector" so to speak). Simple math! In addition, save the 3D point, where the fleet enters that cube and where it will leave it (for path reconstruction later on). Now do that for all cubes of the fleets flight path and save all in the database (a table with 6 columns: [i]path_id, cube_id, time_entering, time_leaving, point_entering, point_leaving[/i]). So, if a fleet moves now, there a several rows saved in the database, consisting of a number of cubes (each one has its own table row). And all belongs to your fleets current path (= [i]path_id[/i]) ----------------------------- Now, if you compute the path of another fleet, you will get their according cubes too. You can check then the current cube where the fleet belongs to against all rows in the database of the same cube, where current time is between entering and leaving time of the other path ids. (the according select query is really simple) If you found another fleets path this way, you know there a two fleets in this sector at the same time. You know both paths (thanks two the two time values and points saved for each cube). Now you can check, if they intersect while moving through this cube/sector. [quote name='Sendo' timestamp='1301310362' post='4791275']...cube size and distance between cube center is controlled by 2 variables...but the amount of rows could quickly go into 100's of thousands even millions...[/quote] No, your cubes/sectors would be defined because they build up the coordinate system. Just don't make the cubes to small. Maybe a normal flight path passes through 10 cubes. 10000 rows for 1000 moving fleets aren't much for a database. Whenever you have to compute a path, you just have to check ONE cube/sector and all the other fleets of the current time frame in there. I hope you did understand what i wanted to say
  4. You didn't tell us, of which type your [i]width[/i] variable is. This will explain my comprehensive statement below. [quote name='Gamer Gamester' timestamp='1300573358' post='4788074']... [code]if ( !== width) = width;[/code] Or ... [code] = width;[/code] ... [/quote] In your first code example you are using the strict equals operator (=== or !==), so your [i]width[/i] variable has to be of type string (Otherwise it will result to false every time). Comparing strings isn't the best choice. In addition, the [i]width[/i] property of the [i]style[/i] object will be an empty string, if you haven't assigned an initial value through JavaScript first or if you haven't defined an inline style attribute in the according HTML tag (No, you won't do that normally). In your second example you have to assign a string, because [i]style[/i] properties have to be strings (That is, because of it beeing a reference to the inline style attribute of an HTML element, see [url=""]W3C DOM Specification[/url] and the DOMstring type used there). The interpreter has to parse that to know that it is the same value as before the assignment. It can't optimize that out like FlimFlam said. (If you assign a variable which isn't a string, the interpreter will convert it first or it will assign an empty string, which depends on the browser. FF4 does assign an empty string btw.) To circumvent a string comparison which isn't needed, i use an additional variable like below (I do that ,if i compare the values many hundred times per second, when a string comparison would outweight a number comparison plus an additional property assignment): [code] // on initialization myElement = { width: 100, // note here, that property width is NOT of type string style: } = myElement.width + 'px' // this line is like your second example, but with explicitly assigning a variable of type string ... // later in code var width = 150 // note here, that variable width is NOT of type string width += 20 ... // while using that element if (myElement.width !== width) { // note here, that there is no string comparison = width + 'px'; myElement.width = width } ... [/code] [quote name='Gamer Gamester' timestamp='1300573358' post='4788074']...In my case, it will usually [u]already be set[/u] correctly, but [u]every now and then will be changing[/u]...[/quote] Do it like your second example, but remember assigning a variable of type string to be precise in your code.
  5. [web] PHP bug?

    [quote name='Cygnus_X' timestamp='1298390574' post='4777554']...What is the advantage of having a static class?...I'm guessing you'd want to do this to save a call to _constructor()?... [/quote] Oh no, not for saving an anyway cheap function call. Static members and methods are used in software engineering. You as the developer of a class know how it is implemented. The next developer, who just uses this class, don't need to know the internals. A factory method is a perfect example for a static method. The method is implemented with the knowledge how to create an instance of a specific inherited class. The user just needs to know the static factory method, which creates an instance of that specific class.
  6. [web] php termination

    [quote name='ms75214' timestamp='1298152419' post='4776441'] how do you terminate a PHP script and ensure the footer still gets printed? [/quote] With proper [b]exception handling[/b]! Instead of terminating the script immediatly, throw an exception. Imho if there is an [i]exit()[/i] or [i]die()[/i] statement somewhere in the script, it can be rewritten in a more maintainable/readable way. [i]exit()[/i] and [i]die()[/i] are like [i]GOTO[/i]. They are "evil" in terms of maintainability. You can't just rely on scope, you have to scan the whole script and every line of code for such statements. [code] include('header.php'); try { ... // do sth or throw an exception ... } catch (Exception $e) { echo('error!'); } include('footer.php') [/code]
  7. [quote name='v0idnull' timestamp='1297964198' post='4775480']...One last thing:...Neither Jeff nor Rachel are online when the attack is scheduled to happen...the attack still has to take place...[/quote] Why it has to take place? Neither Jeff nor Rachel is online, so who wants to know how this attack ended? If you answer this question, than you know what you need. Updates on page refresh, cron jobs or your own dedicated realtime webserver.
  8. [quote name='hojo118' timestamp='1297895036' post='4775148']...Example: A player wants an email notification when a particular resource threshold or event occurs...This seems to require a cron job and I do not know how it is resolved with just in time updating....[/quote] You answered your own question. The magic word here is: "[b]GAME DESIGN[/b]". Start designing your browser based game AROUND these problems! Do not want to cramp your ideas into a framework, which isn't supposed to support such requirements. If you want player ranks updated in realtime, than you don't want a browser based game with ticks per hour. If you want email notification on events, than you don't want a browser based game with updates per user request. If you just need updates per user request, than you don't need cron jobs. etc....... The "big" companies don't have magic solutions to these kind of requirements, they just use the right tool for the right job. And they know, what they have at disposal, so they can design their games accordingly.
  9. [web] Country Lists

    [quote name='ThreeMarks' timestamp='1297353222' post='4772409']...Do they populate the list with a data file? If so, does anyone know where I can get hold of such country/continent lists?...[/quote] Ohhh, come on. [url=""]Let me google that for you[/url]
  10. For serving websites, you need a webserver. A simple one will just deliver static files, which were requested by the browser. If you want to generate dynamic files (with PHP, Python, ...) for every request, the webserver (Apache, lighttpd, Nginx, ...) need to know a way to do that. Either by calling an external program/process with input parameters and relaying the produced output to the browser (CGI, FastCGI, WSGI, ...). By producing the file within an own method/thread, because the according interpreter is embedded as a plugin in the server (mod_python, ...). Or by beeing written in that specific language itself and with the ability to interpret further script files in that language (CherryPy, ...)
  11. [web] mysql select and insert

    Quote:Original post by Black Knight INSERT IGNORE ... Seems to work. I will have to make a SELECT query to get the values back after calling this... Imho this is a bad habit. Running your code this query will fail in 99 percent of all calls, because the player exists already. The error caused by that query will be ignored, but anyway, it is a call to the database, which costs execution time. And that code is hard to read/understand for the next person (even yourself in 3 months) who should work with it, because with that execution flow it is hard to understand what your intention was with that code. Quote:Original post by Black KnightI am trying to get data from a table and if the data doesn't exists i want to create a row and set default values... What is the problem with just using the standard SELECT statement and if it returns no result branch off to the INSERT statement (and a further SELECT, or if you have the defaults in your PHP code already no further SELECT)? This way the code block will execute in 99 percent of the calls without any (ignored) errors and uses just 1 query statement. And in 1 percent of all calls it will execute the if branch with another query too. // PSEUDO CODE runQuery("SELECT ..."); if (getNumRows() == 0) { runQuery("INSERT ... VALUES($default)"); $player_stat = $default; } else { $resultrow = fetchRow(); $player_stat = $resultrow["level"]; }
  12. [web] PHP - Deleting Childs

    As of PHP 5.0, SimpleXML is part of PHP. It requires the libxml PHP extension. <?php $xml = simplexml_load_file('test.xml'); // write new xml to buffer $buffer = "<user>\n"; foreach($xml->children() as $child) { if ("$child" !== "joe") $buffer .= "<friend>$child</friend>\n"; } $buffer .= "<user>\n"; // write buffer to file $file = fopen('test.xml', 'w'); fwrite($file, $buffer); fclose($file); ?> [Edited by - Anntor on November 15, 2010 12:06:18 PM]
  13. Quote:Original post by sending messages as strings and decoding them on the other side okay? ... Or is this too inefficient? Is there a better way to do it? If this is okay depends on the protocol you are using, on the requirements of your application and on the traffic caused by it. There are two ways in general, ascii data (= strings) or binary data: - If all your packets, either ascii data or binary data, are below the packet size treshold (= MTU) it makes no difference in latency to the server. - On the other side, your approach needs parsing of the string, that could cause a bit more processing time than interpreting the raw binary data. - Next is the size needed to send an information in both formats. You gave the example "345,123". That are 7 characters (= 7 bytes) in ascii data, but could be represented with 4 bytes in binary data also (2 bytes for each number ranging from −32768 to 32767). The lower byterate per message means less traffic for each packet to send. And in turn this means less cost caused by (binary data) traffic.
  14. Quote:Original post by Black Knight Is there any difference between this ... and this ... Because the outer anonymous function is executed in the global execution context, no, they are practically the same. Both pointing to the same global object (inside the anonymous function this points to the activation/variable object, which in turn is determined by the caller, which in turn is the global object). Quote:Original post by Black Knight...Isn't my_temporary_variable still private to the anonymous function?... You're right.
  15. Javascript jump code doesn't work o

    Quote:Original post by Fl4sh Wierd ... is empty for some reason... There's a reason behind that. The style object in javascript is a reference to the inline style property of an HTML element. If you set your elements style with separate css blocks, than you can't access that through javascripts style object. separate css style applied to that element (you can't use javascript style object to access this): <style type="text/css"> div {bottom: 33px;} </style> <div id="char"></div> inline style attribute (here you can use the style object in javascript): <div id="char" style="bottom: 33px;"></div> Different browsers offer different ways to retrieve the computed, final style of an element after all CSS rules got applied to it. But these methods return different results between different browsers. So they are not the best choice. (But sometimes the only one depending on the applications requirements) There is only one solution, which works cross browser: Properties of the style attribute you want to change dynamicly should be set with javascript before using them from within javascript. That way the element get its own inline style attribute assigned. example: <script type="text/javascript"> = '33px'; // assign it for the first time { bottom = parseInt(, 10); // here you can access it } </script> <div id="char"></div>