Finally getting somewhere thanks to you guys. I appreciate it. I do have a question and google has failed me.
I'm using dup2 (if anyone knows what that is...) to redirect the output from one file to another file. The problem is, after I use dup2 it basically shuts off the entire output of the program from then on. Does anyone know how to get the dup2 back? I'll post my redirect function:
It's hard to say without a working example, but my natural reaction would be to do the following:
void redirect(char *bef, char *aft)
{
int fd;
int tmpfd; /* NEW */
int k = findCmd(bef,types);
if(k >= 0)
{
fd = open(aft, O_CREAT | O_WRONLY);
tmpfd = dup(1); /* NEW: create a copy so we can restore it later */
close(1);
dup(fd);
invokeCmd(k,arg);
close(1); /* NEW: get rid of our replacement */
dup(tmpfd); /* NEW: put the old fd 1 back into the open slot */
close(tmpfd); /* NEW: close off the copy */
}
}
Assuming that works, a lot of those calls should probably be tested to see if they return error codes.
So everything is done on the project except piping.
From what I can read we're supposed to do ls | cat, and that will take the directory of our virtual drive, and use the cat function of the real computer. If that makes sense.
So using dup2, I was thinking it had to do this:
close the read, open for write, output ls, close output, open the read, input into cat, close the read.
Does that make sense? It doesn't seem to work for me though.
So, I finally have time to get back to work on my ASP.NET/C# game, and I find myself stuck with trying to figure out how to apply status effects to characters during combat. Status effects are a very late, not-originally-planned-for component, and I find myself a bit boxed in by the current system, and I really don't want to rewrite the rest of the combat system.
My biggest hurdle is attempting to actually map the effects to the characters. I originally wanted a Dictionary of effects-to-characters in my CombatEngine object - which is a facade/container for the entire system - but there's no easy way to work that info back up the chain. So, now I'm thinking of making the effects Observers of the characters. After every turn, the character will notify the status effects that the turn has passed. The effects will then either act upon the character, or, if their time is up, detatch themselves from the character.
What do you think?
EDIT: I think I figured out how to do it the 'right' way, so never mind.
Nightslyr on
PSN/XBL/Nintendo/Origin/Steam: Nightslyr 3DS: 1607-1682-2948 Switch: SW-3515-0057-3813 FF XIV: Q'vehn Tia
I don't understand your code as a whole, but I know it's your first shot so it's probably less than ideal.
If I were going from scratch, effects would be properties of the character itself, and my combat engine would calculate status effects per turn per character (including NPC's)
I actually intentionally kept them separate from the character/NPC classes because they didn't seem to be an integral part of those classes logicality, and I didn't want to just stuff the effects into those classes just because it's the easiest thing to do. I'm still trying to feel my way through a sort of theoretical ideal vs. practicality.
My biggest problem lies with how the attacks are actually invoked. There's an extra layer of abstraction at play. I can't show my code now (I'm disabled and in bed, so I'm writing this on my PS3), but essentially it's like this:
The CombatEngine object is created when the user is shuttled to the combat page due to a random encounter. It's initialized by the user's PlayerCharacter object and an Enemy object which is created by data from the db. PlayerCharacter attacks are invoked by a button's click event, which is tied to a method in CombatEngine to execute the attack property. That's all pretty straight forward. The complexity is in the PlayerCharacter and Enemy classes.
Due to the similarities between the two, I decided that they could derive from a base Character class. To help keep the class code clean, especially when loading Character data from the db, I chunked the data into small helper classes. The CharAttacks class keeps a List<Attack> of the attacks a Character has access to as well as the means to actually execute the correct attack. That helper class unfortunately adds another method call to the process.
So, after all that said, a PlayerCharacter attack is executed like so:
The CharAttacks bit is the weakest part of the process. While CombatEngine may seem a bit redundant, it's a tidy place to handle the combat output and state changes, as well as giving the client code a pretty simple interface to work with for all combat-related functionality. CharAttacks, on the other hand, is definitely an unnecessary component as-is. Although, in my sleep-deprived state , Ijust realized I'm an idiot for using it the way I am.
So, thanks for letting me blab and brainstorm. I'll keep my inane ramblings in this post in case it generates more suggestions or advice.
Nightslyr on
PSN/XBL/Nintendo/Origin/Steam: Nightslyr 3DS: 1607-1682-2948 Switch: SW-3515-0057-3813 FF XIV: Q'vehn Tia
I cannot wait to see what kind of nightmare that turns out to be. To me this sounds like instead of trying to improve Flash's performance and work from there they've just gone the "fuck it, we'll just turn each FLA into its own resource-hogging crash-inducing app" route.
But that's probably not fair of me, and Adobe's probably spent a lot of time and resources on this so I'll just sit back and see how this plays out.
No, what it is is that Apple won't let them put Flash in the web browser for some stupid goddamn reason so Adobe figures they need to get on there somehow.
Expect apps made with this to be rejected for seemingly random reasons. But then, that's the App Store for ya.
Two factors in what Apple is doing:
1. locking out third party development platforms, obviously. You can look at this from a lot of different angles. It's monopolistic. It's a stand for only allowing standard web technologies on the iPhone (I agree that so much of the internet's content requiring the proprietary flash plugin is lame). It keeps security issues simple for Apple.
2. Flash is a complete resource hog on a PC let alone a portable device. Why the hell would you want to run any kind of Flash on your iPhone? You can kiss your battery goodbye with even simple stuff.
No, what it is is that Apple won't let them put Flash in the web browser for some stupid goddamn reason so Adobe figures they need to get on there somehow.
Expect apps made with this to be rejected for seemingly random reasons. But then, that's the App Store for ya.
There is a reason and it's not stupid at all. Apple, through their crash report service, has discovered that the number one cause of any app crashing on Mac OS X for any reason is a web browser crashing because of the Flash plugin. Flash is the number one cause of all crashes on Mac OS X. They are justifiably wary.
I just recently started learning C # and I have some questions regarding saving information and retrieving information.
For example, let's say I am making an application for a business that keeps track of employee information. The end user puts information into a bunch of text boxes, presses a button, and the information is saved. Also, if the employee starts up the program again, he or she is able to access this information to view or modify it.
Do I use a database for this? If so, when I compile the program, do I have to include the database software in it or something?
The whole thing confuses me. Any clarification would be helpful. Thanks.
I just recently started learning C # and I have some questions regarding saving information and retrieving information.
For example, let's say I am making an application for a business that keeps track of employee information. The end user puts information into a bunch of text boxes, presses a button, and the information is saved. Also, if the employee starts up the program again, he or she is able to access this information to view or modify it.
Do I use a database for this? If so, when I compile the program, do I have to include the database software in it or something?
The whole thing confuses me. Any clarification would be helpful. Thanks.
The database portion really really depends on how big your application is and how much data you need to handle. You could put DataTables into a DataSet and just use the DataSet.WriteXml(...) method to save the data to disk. When your app starts up again you'd just use DataSet.ReadXml(...) and you've got all of your data back in the app. If you only have a need for 1 table (unlikely) then you can even do DataTable.WriteXml(...) and DataTable.ReadXml(...).
They could also just use the SQL server that tends to be installed alongside Microsoft's free IDE's. If they're used to a PHP environment, that's the closest thing to it.
EDIT: this post aimed towards iTunes and MiserableMirth.
Nightslyr on
PSN/XBL/Nintendo/Origin/Steam: Nightslyr 3DS: 1607-1682-2948 Switch: SW-3515-0057-3813 FF XIV: Q'vehn Tia
I'm enjoying Silverlight for video of late. Though I'm not sure how it actually does performance-wise. I do seem to have less issues with Silverlight video though. Anecdotal etc etc.
And you're limited to Microsoft-blessed platforms. Linux runs a lot of phones these days, and I haven't heard anything good about Moonlight.
This is true, but I've been watching NFL Sunday Night games on ABC's site w/ Silverlight on an Ubuntu box, and I watch a lot of Netflix on my Win 7 and Snow Leopard machines.
The database portion really really depends on how big your application is and how much data you need to handle. You could put DataTables into a DataSet and just use the DataSet.WriteXml(...) method to save the data to disk. When your app starts up again you'd just use DataSet.ReadXml(...) and you've got all of your data back in the app. If you only have a need for 1 table (unlikely) then you can even do DataTable.WriteXml(...) and DataTable.ReadXml(...).
I toyed around with this, and got it to work. Thanks!
They could also just use the SQL server that tends to be installed alongside Microsoft's free IDE's. If they're used to a PHP environment, that's the closest thing to it.
I doing this now.
One question though, if I use a the SQL server and I install my finished program on another computer, do they need to have to have the SQL server installed on their computer as well?
They could also just use the SQL server that tends to be installed alongside Microsoft's free IDE's. If they're used to a PHP environment, that's the closest thing to it.
I doing this now.
One question though, if I use a the SQL server and I install my finished program on another computer, do they need to have to have the SQL server installed on their computer as well?
AFAIK, yes, just like with every other database-driven application.
Nightslyr on
PSN/XBL/Nintendo/Origin/Steam: Nightslyr 3DS: 1607-1682-2948 Switch: SW-3515-0057-3813 FF XIV: Q'vehn Tia
Use SQL if you can expect that your application will be used in environments where a knowledgeable person will be setting it up for users (workstation, server), and XML for environments where users are likely to be on their own.
The former because it needs SQL server, and the latter because XML stuff is handled within the framework.
Video? jesus christ. Never play video through Flash.
The absolute and total convenience of using Flash as a video player is the current main reason for it's total ubiquity at the moment.
Also, a fair few AAA PC game use Flash for the menu system because it just works and frees the programmers up from having to implement yet another basic GUI system.
The first rule of reflection club is: why do you want to use reflection?
Because so far they've taught me nothing about it in school, I've come across the topic while doing a research paper and knew nothing about it, and finally...
The first rule of reflection club is: why do you want to use reflection?
Because so far they've taught me nothing about it in school, I've come across the topic while doing a research paper and knew nothing about it, and finally...
You don't need to know reflection to be a better programmer.
But better understanding your tools is absolutely one way to get better, and reflection is an important topic that can save you a ton of work in the right circumstances
You don't need to know reflection to be a better programmer.
But better understanding your tools is absolutely one way to get better, and reflection is an important topic that can save you a ton of work in the right circumstances
I've been doing a lot of C++ work lately, and the lack of reflection is a tremendous PITA for some things. Knowing reflection and what you can do with it is important. Much easier to start with Python or a scripting language though; I found the .NET way of doing things pretty confusing. Java isn't much better with it's lol here catch 10 exceptions every time you want to do dynamic binding.
You don't need to know reflection to be a better programmer.
But better understanding your tools is absolutely one way to get better, and reflection is an important topic that can save you a ton of work in the right circumstances
Use SQL if you can expect that your application will be used in environments where a knowledgeable person will be setting it up for users (workstation, server), and XML for environments where users are likely to be on their own.
The former because it needs SQL server, and the latter because XML stuff is handled within the framework.
You don't need knowledgeable users or separate servers to use SQL. Using SQL from the get go can be good because it's a standard way to access a database and allows your program to switch to a distributed / remote system much much easier than using XML ever will. (If you grow into multiple clients, you don't need to rewrite your application data layer, etc.)
This is why things such as SQLite exist, they give you a setup-free (for the user) and lightweight means of working with SQL in a simple application. Or complicated application. If you use Firefox, you're using SQLite without even necessarily knowing about it.
Use SQL if you can expect that your application will be used in environments where a knowledgeable person will be setting it up for users (workstation, server), and XML for environments where users are likely to be on their own.
The former because it needs SQL server, and the latter because XML stuff is handled within the framework.
You don't need knowledgeable users or separate servers to use SQL. Using SQL from the get go can be good because it's a standard way to access a database and allows your program to switch to a distributed / remote system much much easier than using XML ever will. (If you grow into multiple clients, you don't need to rewrite your application data layer, etc.)
This is why things such as SQLite exist, they give you a setup-free (for the user) and lightweight means of working with SQL in a simple application. Or complicated application. If you use Firefox, you're using SQLite without even necessarily knowing about it.
I was speaking specifically about .NET and MSSQL, which as far as I can tell is what he was asking about.
Use SQL if you can expect that your application will be used in environments where a knowledgeable person will be setting it up for users (workstation, server), and XML for environments where users are likely to be on their own.
The former because it needs SQL server, and the latter because XML stuff is handled within the framework.
You don't need knowledgeable users or separate servers to use SQL. Using SQL from the get go can be good because it's a standard way to access a database and allows your program to switch to a distributed / remote system much much easier than using XML ever will. (If you grow into multiple clients, you don't need to rewrite your application data layer, etc.)
This is why things such as SQLite exist, they give you a setup-free (for the user) and lightweight means of working with SQL in a simple application. Or complicated application. If you use Firefox, you're using SQLite without even necessarily knowing about it.
I was speaking specifically about .NET and MSSQL, which as far as I can tell is what he was asking about.
How does that change anything with regards to "use XML instead of SQL"? That is what I'm addressing, because you make it sound like SQL is too heavy-handed and I'm pointing out alternatives that maybe be more suitable.
Using SQL as a developer does not mean your users will be required to have special knowledge.
Use SQL if you can expect that your application will be used in environments where a knowledgeable person will be setting it up for users (workstation, server), and XML for environments where users are likely to be on their own.
The former because it needs SQL server, and the latter because XML stuff is handled within the framework.
You don't need knowledgeable users or separate servers to use SQL. Using SQL from the get go can be good because it's a standard way to access a database and allows your program to switch to a distributed / remote system much much easier than using XML ever will. (If you grow into multiple clients, you don't need to rewrite your application data layer, etc.)
This is why things such as SQLite exist, they give you a setup-free (for the user) and lightweight means of working with SQL in a simple application. Or complicated application. If you use Firefox, you're using SQLite without even necessarily knowing about it.
I was speaking specifically about .NET and MSSQL, which as far as I can tell is what he was asking about.
How does that change anything with regards to "use XML instead of SQL"? That is what I'm addressing, because you make it sound like SQL is too heavy-handed and I'm pointing out alternatives that maybe be more suitable.
Using SQL as a developer does not mean your users will be required to have special knowledge.
If he uses MSSQL, his users would need to install MSSQL server.
Posts
It's hard to say without a working example, but my natural reaction would be to do the following:
void redirect(char *bef, char *aft) { int fd; int tmpfd; /* NEW */ int k = findCmd(bef,types); if(k >= 0) { fd = open(aft, O_CREAT | O_WRONLY); tmpfd = dup(1); /* NEW: create a copy so we can restore it later */ close(1); dup(fd); invokeCmd(k,arg); close(1); /* NEW: get rid of our replacement */ dup(tmpfd); /* NEW: put the old fd 1 back into the open slot */ close(tmpfd); /* NEW: close off the copy */ } }Assuming that works, a lot of those calls should probably be tested to see if they return error codes.
From what I can read we're supposed to do ls | cat, and that will take the directory of our virtual drive, and use the cat function of the real computer. If that makes sense.
So using dup2, I was thinking it had to do this:
close the read, open for write, output ls, close output, open the read, input into cat, close the read.
Does that make sense? It doesn't seem to work for me though.
My biggest hurdle is attempting to actually map the effects to the characters. I originally wanted a Dictionary of effects-to-characters in my CombatEngine object - which is a facade/container for the entire system - but there's no easy way to work that info back up the chain. So, now I'm thinking of making the effects Observers of the characters. After every turn, the character will notify the status effects that the turn has passed. The effects will then either act upon the character, or, if their time is up, detatch themselves from the character.
What do you think?
EDIT: I think I figured out how to do it the 'right' way, so never mind.
Switch: SW-3515-0057-3813 FF XIV: Q'vehn Tia
I don't understand your code as a whole, but I know it's your first shot so it's probably less than ideal.
If I were going from scratch, effects would be properties of the character itself, and my combat engine would calculate status effects per turn per character (including NPC's)
My biggest problem lies with how the attacks are actually invoked. There's an extra layer of abstraction at play. I can't show my code now (I'm disabled and in bed, so I'm writing this on my PS3), but essentially it's like this:
The CombatEngine object is created when the user is shuttled to the combat page due to a random encounter. It's initialized by the user's PlayerCharacter object and an Enemy object which is created by data from the db. PlayerCharacter attacks are invoked by a button's click event, which is tied to a method in CombatEngine to execute the attack property. That's all pretty straight forward. The complexity is in the PlayerCharacter and Enemy classes.
Due to the similarities between the two, I decided that they could derive from a base Character class. To help keep the class code clean, especially when loading Character data from the db, I chunked the data into small helper classes. The CharAttacks class keeps a List<Attack> of the attacks a Character has access to as well as the means to actually execute the correct attack. That helper class unfortunately adds another method call to the process.
So, after all that said, a PlayerCharacter attack is executed like so:
Button click -> CombatEngine attack method -> Character attack method -> CharAttacks attack method -> Attack object's Execute() method
The CharAttacks bit is the weakest part of the process. While CombatEngine may seem a bit redundant, it's a tidy place to handle the combat output and state changes, as well as giving the client code a pretty simple interface to work with for all combat-related functionality. CharAttacks, on the other hand, is definitely an unnecessary component as-is. Although, in my sleep-deprived state , Ijust realized I'm an idiot for using it the way I am.
So, thanks for letting me blab and brainstorm. I'll keep my inane ramblings in this post in case it generates more suggestions or advice.
Switch: SW-3515-0057-3813 FF XIV: Q'vehn Tia
Two factors in what Apple is doing:
1. locking out third party development platforms, obviously. You can look at this from a lot of different angles. It's monopolistic. It's a stand for only allowing standard web technologies on the iPhone (I agree that so much of the internet's content requiring the proprietary flash plugin is lame). It keeps security issues simple for Apple.
2. Flash is a complete resource hog on a PC let alone a portable device. Why the hell would you want to run any kind of Flash on your iPhone? You can kiss your battery goodbye with even simple stuff.
Edit: 3. VVVVVV what he said VVVVV
There is a reason and it's not stupid at all. Apple, through their crash report service, has discovered that the number one cause of any app crashing on Mac OS X for any reason is a web browser crashing because of the Flash plugin. Flash is the number one cause of all crashes on Mac OS X. They are justifiably wary.
For example, let's say I am making an application for a business that keeps track of employee information. The end user puts information into a bunch of text boxes, presses a button, and the information is saved. Also, if the employee starts up the program again, he or she is able to access this information to view or modify it.
Do I use a database for this? If so, when I compile the program, do I have to include the database software in it or something?
The whole thing confuses me. Any clarification would be helpful. Thanks.
Anytime I hit a site with a bunch of flash stuff everywhere I immediately back out.
People need to stop making flash-centric web pages. Ridiculous sh!t. This isn't the 90s.
EDIT: this post aimed towards iTunes and MiserableMirth.
Switch: SW-3515-0057-3813 FF XIV: Q'vehn Tia
Video, applications, games.
Video? jesus christ. Never play video through Flash.
Do you have a better alternative? OGG isn't widespread, and WMV is platform-locked. Everything else I'm aware of is very heavy.
I doing this now.
One question though, if I use a the SQL server and I install my finished program on another computer, do they need to have to have the SQL server installed on their computer as well?
See how many books I've read so far in 2010
SE++ Forum Battle Archive
AFAIK, yes, just like with every other database-driven application.
Switch: SW-3515-0057-3813 FF XIV: Q'vehn Tia
The former because it needs SQL server, and the latter because XML stuff is handled within the framework.
The absolute and total convenience of using Flash as a video player is the current main reason for it's total ubiquity at the moment.
Also, a fair few AAA PC game use Flash for the menu system because it just works and frees the programmers up from having to implement yet another basic GUI system.
I made a game, it has penguins in it. It's pay what you like on Gumroad.
Currently Ebaying Nothing at all but I might do in the future.
The first rule of reflection club is: why do you want to use reflection?
I made a game, it has penguins in it. It's pay what you like on Gumroad.
Currently Ebaying Nothing at all but I might do in the future.
Because so far they've taught me nothing about it in school, I've come across the topic while doing a research paper and knew nothing about it, and finally...
because it would make me a better programmer?
See how many books I've read so far in 2010
http://www.red-gate.com/products/reflector/
This is more or less what reflection is. Being able to access code underlying an assembly through code.
edit:: I should qualify this with a giant I think. The definitions I've found are kind of squishy.
But better understanding your tools is absolutely one way to get better, and reflection is an important topic that can save you a ton of work in the right circumstances
I've been doing a lot of C++ work lately, and the lack of reflection is a tremendous PITA for some things. Knowing reflection and what you can do with it is important. Much easier to start with Python or a scripting language though; I found the .NET way of doing things pretty confusing. Java isn't much better with it's lol here catch 10 exceptions every time you want to do dynamic binding.
Thats what I was thinking.
See how many books I've read so far in 2010
You don't need knowledgeable users or separate servers to use SQL. Using SQL from the get go can be good because it's a standard way to access a database and allows your program to switch to a distributed / remote system much much easier than using XML ever will. (If you grow into multiple clients, you don't need to rewrite your application data layer, etc.)
This is why things such as SQLite exist, they give you a setup-free (for the user) and lightweight means of working with SQL in a simple application. Or complicated application. If you use Firefox, you're using SQLite without even necessarily knowing about it.
I was speaking specifically about .NET and MSSQL, which as far as I can tell is what he was asking about.
How does that change anything with regards to "use XML instead of SQL"? That is what I'm addressing, because you make it sound like SQL is too heavy-handed and I'm pointing out alternatives that maybe be more suitable.
Using SQL as a developer does not mean your users will be required to have special knowledge.
If he uses MSSQL, his users would need to install MSSQL server.