Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 06 Oct 2003
Offline Last Active May 28 2013 10:26 PM

Topics I've Started

[web] PHP's fpassthru on large files?

29 July 2007 - 02:10 PM

This is my first time posting in the Web Development forum, kinda scary. Anyway, I'm running a site for a group at school which distributes video clips. The problem is, we're only allowed to distribute these clips to students registered with the club (copyrights, DMCA, etc). Additionally, I'd like to be able to log all downloads by something more than just IP address. So, the current version of the system I have up is essentially a PHP script which validates the user's identity, then uses fpassthru to send the file over the tubes. Now, these files can range anywhere from 50-150MB in size, and fpassthru is a blocking function. I haven't yet discussed this with my host (because I'm a candypants), but since this essentially leaves PHP scripts running for the duration of the transfer, I'm a little worried that it might be wasting cycles. For our purposes, there should rarely be any concurrent accesses, at most there might be three people concurrently downloading files. So my question is, for large files will fpassthru be wasteful to the point where the host will have a problem with it? And if so, does anyone have ideas for validation/file sending mechanisms which meet the requirements listed in the beginning? : Thanks for the help :)

Hay I Disproved Ethics (please disprove me)

10 December 2006 - 07:27 AM

So I'm writing a generic ethics paper, and I seem to have gotten myself stuck. The paper itself is just a general discussion of action-based ethics systems with concrete examples, but, well, lemmie just post the crap.
Thus far we have discussed common inconsistencies resulting from an analysis of an ethical dilemma. An ethical dilemma can be described as a “right vs. right” decision: at least two options exist which are not immediately discarded as “wrong”. Ethical frameworks, therefore, exist to determine which action is the most right. For any action, there is at least one option which is more right than the others. This is an implicit fundamental premise of all ethical theory: if all actions are equal there would be no need for ethical analysis. Thus, we can postulate that an inequality exists; therefore there must be a best option (“most right choice”) for any scenario. Likewise, if you take any given ethical dilemma and an ethical framework, when examined from the perspective of Laplace’s demon, you should get a consistent answer, which is the most-ethical choice as defined by the framework. This isn’t to say that every ethical framework will produce the same penultimate answer; since each ethical framework defines “right” differently the solutions they produce will no doubt be different. Regardless, there exists a “most correct” solution for any ethical problem, given an ethical framework. This presents us with a meta-ethical dilemma: which ethical framework will provide the most ethical solution? The question in itself is absurd, requiring an analysis of the basis of the same analysis, resulting in a circular logic from which nothing can be determined.
So what I'm looking for is a reasonable hole in this argument. I don't want to continue the paper with "Setting aside that ethical frameworks are self-justified arbitrary behavioral rule systems..." I PLACE MY FATE IN TEH LOGICAL POWAR OF GDNET! please help me [sad]

Items, Inventories, "Unique" Weapons, and Databases

07 December 2006 - 08:50 AM

I've been working on a PHP web-based (MO)RPG for about a week now, and I've finally gotten to the point where I have to implement inventories. This is one aspect that I haven't come to a decision yet about how I'm going to implement it, because I haven't figured out what, exactly, I want from the system. So I'm asking here for some opinions on some of the options that I've currently got in mind, being mindful of the database structure that each will require. Basics: In every situation, there are (at least) 2 tables: the item 'dictionary', and the player inventory tables. The dictionary contains a row for each item in the game, with its stats, effects, description, etc. The inventory table describes the items currently in the possession of the player. Decision One: Limited or Unlimited Inventory for Non-Equippable Items? Basically, if we take the subset of all the items that might be 'collectable', ie, potions, boar hides, arrows, essentially items in which one would expect no stat variation, we have two choices: limit the number of different items one can carry, or not. My explanation is poor, as usual, but this decision determines the structure of the inventory table. In the former, where there are limited inventory slots, the table becomes a set number of item#/quantity matchings - playerid | item1id | item1count | ... itemNid | itemNcount Where N is the maximum inventory size. The other option is slightly more space demanding, since we can potentially have every item in the game at once - playerid | countofitem#1 | countofitem#2 | ... countofitem#N Where N is the number of items in the database. I personally have no opinion on this one, but am leaning towards a combination of the two - have the player's "out in the field" inventory be limited to a set number of items, and have an unlimited storage space back in the city. This adds an equipment strategy dynamic, since it takes time to walk back and forth between the city and other areas. Regardless - this only works for items in which every 'copy' of an item is identical to every other item. (a 'rock' is always a 'rock' and shares the same qualities as every other 'rock'). Decision Two: Items with 'Unique' Qualities..? This is where things get a little complicated. For things like equipment, I'd like to have a bit of diversity. Maybe this piece of leather armor is beaten up, and thus doesn't provide as much protection as that piece of leather armor. Or maybe this steel sword has an enchantment which causes it to turn orcs into chickens when the moon is full. Or maybe it just has slightly different stats than the others. Basically, things that add flavor and diversity. Option 1: Pre-calculated Permutations The cheapest solution to this (using an existing solution described above) is to make each possible item its own item with its own unique item ID, ie, "beaten-up leather armor" and "leather armor" are completely unrelated items, except they have the same name and picture. I think this is an unacceptable method, simply because... ugh, it requires excess stupid work to generate all possible permutations. Option 2: 'Identical' Items and 'Deviant' Items If we instead break out of our "each item is identical" (as defined in the item dictionary), we need to add more stuff to our inventory layout, since we need to have more data to define what's unique about this particular instance of the weapon. We need a method to define this uniqueness, though... Option 2a: Enumerated Differences This is the approach used by Space Cowboy Online - each weapon could have a prefix and a suffix. The prefix and suffix were, essentially, fixed stat modifiers which acted on the weapon's base stats. Since each weapon could only have, at max, one prefix and one suffix, the system wasn't too unmanagable, but a little limited. For example, there would be no easy way to enumerate the remaining durability of a weapon. Option 2b: Explicit Differences Conversely, we could explicitly say that each weapon is BASE+13 DAMAGE, FREEZE ATTRIB, 58% DAMAGED. This would provide the maximum amount of flexibility, but essentially kills the entire point of having an item dictionary. Which is bleeehhhh because it would take up quite a bit of space. Conclusion: Basically, I haven't been able to think of a solution I like to this problem. The constraints are -
  • It must provide a flexible system allowing a diverse range of weaponry
  • It must be... sane to implement (with respect to table layout)
Opinions/Comments on my current ideas? I'm really lost right now :(


06 October 2006 - 04:38 PM

Okay, so capn_midnight's thread has prompted me to spawn something. Didn't really matter what it was, as long as I tried to make some effort to do it. In any case - one of my favorite threads on the lounge have been when Chemical_Imbalance posts a fun little D&Dish thread where we all eat rope and such. The problem with those is that he eventually has to go to sleep, and then it gets kind of boring. So I've come up with a solution! Each person is the wizard/DM/GM/piemaster of the previously posted post. Also, some more rules -
  1. Rope tastes like chicken.
  2. There is no more than one brothel in every other town.
  3. You're not allowed to kill, cripple, castrate, mutilate or rape more than one person in a single post.
  4. Each post must have either a meaningful 'results of command', or a command to be executed.
  5. In the case that the ropes of the storyline begin to untwine, refer to rule #1.
  6. You do not talk about fightclub.
  7. There are no rules.
Anyway. I'll start the story -
Long ago, a small but mighty humanoid kingdom existed in what is now the local wilderness. Bugbear and ogre warriors fought brutal wars of expansion, earning great fame and amassing considerable fortunes from their predations. Those who died in battle were buried in large tomb complexes dug into hillsides and honored as patrons of the living. Among these tombs was the large tor known as Hightower. Though it was neither the largest nor the most famous of the kingdom's tombs, Hightower did represent a typical example of this kind of structure. As happens to all such nations, the cruel humanoid kingdom eventually fell to a more powerful foe that razed all its cities and outlying fortifications. Of the tombs, only Hightower escaped destruction -- largely because it was an unimportant monument in a remote location. A few tribes of humanoids that survived the devastation tried to use it as a fortress, but the humans with whom they clashed defeated them soundly and sealed the entrance with a huge, round stone to ensure that the tor could no longer be used as a base. Since then, Hightower has served as a landmark for travelers in the know, but it has otherwise been largely forgotten. But the electrical storms that have plagued the area in recent days have been quite severe, and a few weeks ago, a stray lightning bolt broke open the stone seal. Tonight, yet another terrible storm is sweeping through the wilderness, driving all creatures to take shelter where they can find it. Hightower looms on the horizon, and its door is no longer blocked. > [Edited by - Mushu on October 6, 2006 11:16:14 PM]

lol @ templates (working title)

29 September 2006 - 05:35 PM

Okay, so I'm having a problem in my code. I don't really know how to describe it, since I'm not really sure wtf is going on. Essentially, the wrong template parameters are being choosen or something. Arg. I'm going to try to re-read the template chapter of the book, but doubt I'll finish it. Anyway, my problem. Hrm, where to begin. Basically I'm goofing around and writing a non-intrusive python embedding library (if you're one of those people who enjoy context). Basically, we have a happy function, say - int callPyFunc( char* arg ); We want to pass this function pointer to a function which exposes it to python - python::expose<int, char*>( "call", &callPyFunc ); Now, I know I don't need the template parameters there, its just for purposes of clarity. Right. So this is where things get icky... The corresponding templated overload of expose looks like this -
template < class R, class A1 >
void expose( const std::string& name, R( *func )( A1 ) ) {
	details::CFuncStub stub;
	stub.func = func;
	stub.call = &details::_ArgParser<R>::parse<A1>; // WHAT.
	details::_addCFunc( name, stub );
The problem occurs on the commented line. This is where things get icky. Really icky. Actually, let me explain/justify part of this mess first. Basically, we cast the function pointer to a void*. We then cache a pointer to a corresponding function which takes a void*, casts it to the right pointer and does crazy Python stuff and stuff. That's the commented line. Ack, lemmie just post the monster. Trimmed down, of course.
template < class R >
struct _ArgParser {
	template < class A1 >
	static PyObject* parse( PyObject* args, void* func ) {
		typedef R ( *FUNCTYPE )( A1 );
		FUNCTYPE realfunc = ( FUNCTYPE ) func;
		const char* name = NULL;
		A1 a1;

		if ( PyArg_ParseTuple( args, _getFmtString<char*,A1>().c_str(), &name, &a1 ) ) {
			return _returnObject<R>( realfunc( a1 ) );

		return NULL;

	template <>
	static PyObject* parse<void>( PyObject* args, void* func ) {
		typedef R ( *FUNCTYPE )( void );
		FUNCTYPE realfunc = ( FUNCTYPE ) func;
		return _returnObject<R>( realfunc() );
Go ahead and digest that. Now, given that the function we're exposing has the signature int(*)(char*) and explicitly call python::expose<int,char*>, we assume that stub.call gets set to - &details::_ArgParser<int>::parse<char*> Sadly, this is not the case. It gets set to the explicitly defined &details::_ArgParser<int>::parse<void> Which breaks it [sad]. How do I fix this behavior? The only thing I can think of is to wrap in another struct like _ArgParser which handles the special case where the function takes no parameters. _ArgParser handles the special case where the function returns nothing. Nested templated structs seems a bit ... messy. Anything better out there? And I've no idea why its even doing this...