dev-cpp-users Mailing List for Dev-C++ (Page 44)
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
You can subscribe to this list here.
2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(15) |
Oct
(115) |
Nov
(154) |
Dec
(258) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(377) |
Feb
(260) |
Mar
(249) |
Apr
(188) |
May
(152) |
Jun
(150) |
Jul
(195) |
Aug
(202) |
Sep
(200) |
Oct
(286) |
Nov
(242) |
Dec
(165) |
2002 |
Jan
(245) |
Feb
(241) |
Mar
(239) |
Apr
(346) |
May
(406) |
Jun
(369) |
Jul
(418) |
Aug
(357) |
Sep
(362) |
Oct
(597) |
Nov
(455) |
Dec
(344) |
2003 |
Jan
(446) |
Feb
(397) |
Mar
(515) |
Apr
(524) |
May
(377) |
Jun
(387) |
Jul
(532) |
Aug
(364) |
Sep
(294) |
Oct
(352) |
Nov
(295) |
Dec
(327) |
2004 |
Jan
(416) |
Feb
(318) |
Mar
(324) |
Apr
(249) |
May
(259) |
Jun
(218) |
Jul
(212) |
Aug
(259) |
Sep
(158) |
Oct
(162) |
Nov
(214) |
Dec
(169) |
2005 |
Jan
(111) |
Feb
(165) |
Mar
(199) |
Apr
(147) |
May
(131) |
Jun
(163) |
Jul
(235) |
Aug
(136) |
Sep
(84) |
Oct
(88) |
Nov
(113) |
Dec
(100) |
2006 |
Jan
(85) |
Feb
(119) |
Mar
(33) |
Apr
(31) |
May
(56) |
Jun
(68) |
Jul
(18) |
Aug
(62) |
Sep
(33) |
Oct
(55) |
Nov
(19) |
Dec
(40) |
2007 |
Jan
(22) |
Feb
(49) |
Mar
(34) |
Apr
(51) |
May
(66) |
Jun
(43) |
Jul
(116) |
Aug
(57) |
Sep
(70) |
Oct
(69) |
Nov
(97) |
Dec
(86) |
2008 |
Jan
(32) |
Feb
(47) |
Mar
(106) |
Apr
(67) |
May
(28) |
Jun
(39) |
Jul
(31) |
Aug
(25) |
Sep
(18) |
Oct
(25) |
Nov
(5) |
Dec
(21) |
2009 |
Jan
(33) |
Feb
(27) |
Mar
(27) |
Apr
(22) |
May
(22) |
Jun
(10) |
Jul
(17) |
Aug
(9) |
Sep
(21) |
Oct
(13) |
Nov
(4) |
Dec
(11) |
2010 |
Jan
(10) |
Feb
(8) |
Mar
(4) |
Apr
(1) |
May
|
Jun
(2) |
Jul
|
Aug
(1) |
Sep
(8) |
Oct
(26) |
Nov
(9) |
Dec
(1) |
2011 |
Jan
(21) |
Feb
(16) |
Mar
(4) |
Apr
(19) |
May
(26) |
Jun
(9) |
Jul
(6) |
Aug
|
Sep
(4) |
Oct
(3) |
Nov
(2) |
Dec
(1) |
2012 |
Jan
(4) |
Feb
(7) |
Mar
(4) |
Apr
|
May
(1) |
Jun
(10) |
Jul
(1) |
Aug
(1) |
Sep
(18) |
Oct
(3) |
Nov
(1) |
Dec
(1) |
2013 |
Jan
(4) |
Feb
(2) |
Mar
(15) |
Apr
(6) |
May
(1) |
Jun
(3) |
Jul
(1) |
Aug
(2) |
Sep
(4) |
Oct
|
Nov
(9) |
Dec
|
2014 |
Jan
(4) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(5) |
Aug
(4) |
Sep
|
Oct
(2) |
Nov
(1) |
Dec
(4) |
2015 |
Jan
(2) |
Feb
(3) |
Mar
(1) |
Apr
(2) |
May
(1) |
Jun
(2) |
Jul
|
Aug
(1) |
Sep
(2) |
Oct
(9) |
Nov
(35) |
Dec
(6) |
2016 |
Jan
(7) |
Feb
(10) |
Mar
(10) |
Apr
(9) |
May
(13) |
Jun
(9) |
Jul
(1) |
Aug
(3) |
Sep
(3) |
Oct
(1) |
Nov
(1) |
Dec
|
2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2018 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2019 |
Jan
(1) |
Feb
|
Mar
|
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2020 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Per W. <pw...@ia...> - 2007-11-15 10:19:30
|
You can not use a data type before it is fully defined (except for a couple of exceptions, when it comes to pointers and references to incomplete structs or classes). The class Time isn't fully defined when you try to use it in your + operator. Remove the + operator from the Time type. Create a separate (inline) operator+ function outside of the Time class, and let it take two Time parameters. /pwm On Thu, 15 Nov 2007, yun peter wrote: > the attachment includes the program and debug information. > my platform is vista home basic. > I don't know what the reasons are. > > > best regards! > |
From: yun p. <cer...@gm...> - 2007-11-15 08:41:03
|
the attachment includes the program and debug information. my platform is vista home basic. I don't know what the reasons are. best regards! |
From: Per W. <pw...@ia...> - 2007-11-13 20:54:59
|
No need for the "magic" number 9. The "\t" sequence will be replaced with the ASCII number for a tab, i.e. the number 9. Just as the "\r" will be replaced with the ASCII number for a carriage-return, and "\n" with the ASCII number for a line feed etc. The processing of the escape sequences is done by the compiler, not by the C/C++ library, so the translation is always performed, i.e. it doesn't matter how a character constant or string constant is used. /pwm On Tue, 13 Nov 2007, Wobien wrote: > "\t" is supposed to be a tab, but i do'nt know if that works in a textbox. > In one of my progs i succesfully used > char tab=9; > i used a stringstream to format the text for the textbox: > std::stringstream stream; > stream<<"text before tab"<<tab<<"text after tab" ; > stream.str().c_str() is a c-string you can use for your textbox. > > wobien > > > ----- Original Message ----- > From: "Jessica Chen" <jes...@gm...> > To: <dev...@li...> > Sent: Tuesday, November 13, 2007 8:51 PM > Subject: [Dev-C++] how to set "tab" key in textbox of win 32 api > > > >i used "\r\n" as return in the textbox of win 32 api. > > but what is for "tab" in the textbox of win 32 api???? > > > > thanks, > > jessica > > > > ------------------------------------------------------------------------- > > This SF.net email is sponsored by: Splunk Inc. > > Still grepping through log files to find problems? Stop. > > Now Search log events and configuration files using AJAX and a browser. > > Download your FREE copy of Splunk now >> http://get.splunk.com/ > > _______________________________________________ > > Dev-cpp-users mailing list > > Dev...@li... > > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
From: Jessica C. <jes...@gm...> - 2007-11-13 20:48:52
|
hey... that works. On Nov 13, 2007 3:23 PM, Wobien <roo...@pl...> wrote: > "\t" is supposed to be a tab, but i do'nt know if that works in a textbox. > In one of my progs i succesfully used > char tab=9; > i used a stringstream to format the text for the textbox: > std::stringstream stream; > stream<<"text before tab"<<tab<<"text after tab" ; > stream.str().c_str() is a c-string you can use for your textbox. > > wobien > > > > ----- Original Message ----- > From: "Jessica Chen" <jes...@gm...> > To: <dev...@li...> > Sent: Tuesday, November 13, 2007 8:51 PM > Subject: [Dev-C++] how to set "tab" key in textbox of win 32 api > > > >i used "\r\n" as return in the textbox of win 32 api. > > but what is for "tab" in the textbox of win 32 api???? > > > > thanks, > > jessica > > > > ------------------------------------------------------------------------- > > This SF.net email is sponsored by: Splunk Inc. > > Still grepping through log files to find problems? Stop. > > Now Search log events and configuration files using AJAX and a browser. > > Download your FREE copy of Splunk now >> http://get.splunk.com/ > > _______________________________________________ > > Dev-cpp-users mailing list > > Dev...@li... > > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
From: Wobien <roo...@pl...> - 2007-11-13 20:23:23
|
"\t" is supposed to be a tab, but i do'nt know if that works in a textbox. In one of my progs i succesfully used char tab=9; i used a stringstream to format the text for the textbox: std::stringstream stream; stream<<"text before tab"<<tab<<"text after tab" ; stream.str().c_str() is a c-string you can use for your textbox. wobien ----- Original Message ----- From: "Jessica Chen" <jes...@gm...> To: <dev...@li...> Sent: Tuesday, November 13, 2007 8:51 PM Subject: [Dev-C++] how to set "tab" key in textbox of win 32 api >i used "\r\n" as return in the textbox of win 32 api. > but what is for "tab" in the textbox of win 32 api???? > > thanks, > jessica > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users |
From: Jessica C. <jes...@gm...> - 2007-11-13 19:51:41
|
i used "\r\n" as return in the textbox of win 32 api. but what is for "tab" in the textbox of win 32 api???? thanks, jessica |
From: Alessandro B. <ale...@is...> - 2007-11-13 16:16:43
|
Thanks, now it works. Alessandro. Wobien Doyer ha scritto: > Hello Alessandro, > I had problems like that with iterators in const methods. > It was solved by using const_iterator instead, so: > > vector<string>::const_iterator result = > find( elenco.begin(), elenco.end(), a ); > > The strings in the vector are, inside a const method considered to be > const, but a non const iterator points to a non const string. > > > Wobien > > ----- Original Message ----- From: "Alessandro Bugatti" > <ale...@is...> > To: <dev...@li...> > Sent: Monday, November 12, 2007 11:59 PM > Subject: [Dev-C++] Vector and algorithms > > >> Hello, I wrote this method and I receive an error message in >> compilation: >> >> bool Dizionario::inDictionary(const string &a) const >> { >> vector<string>::iterator result = >> find( elenco.begin(), elenco.end(), a ); >> if (result == elenco.end()) return false; >> return true; >> } >> >> 598 C:\Programmi\Dev-Cpp\include\c++\3.3.1\bits\stl_iterator.h invalid >> conversion from `const std::string* const' to `std::string*' >> >> I wonder the problem is in elenco.begin() and elenco.end() and the const >> method (if I erase the keyword const the program is OK, but I don't want >> remove const because the method is const). >> Have I cast elenco.begin() and elenco.end()? In which mode? >> Thanks >> Alessandro >> >> -- >> ************************************************ >> Prof. Alessandro Bugatti >> Docente di Informatica >> Istituto Tecnico Industriale Statale B. Castelli >> E-mail: ale...@is... >> Sito web: www.imparando.net >> ************************************************ >> >> >> ------------------------------------------------------------------------- >> >> This SF.net email is sponsored by: Splunk Inc. >> Still grepping through log files to find problems? Stop. >> Now Search log events and configuration files using AJAX and a browser. >> Download your FREE copy of Splunk now >> http://get.splunk.com/ >> _______________________________________________ >> Dev-cpp-users mailing list >> Dev...@li... >> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm >> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > -- ************************************************ Prof. Alessandro Bugatti Docente di Informatica Istituto Tecnico Industriale Statale B. Castelli E-mail: ale...@is... Sito web: www.imparando.net ************************************************ |
From: Alessandro B. <ale...@is...> - 2007-11-13 16:14:07
|
Sorry, vector <string> elenco; Alessandro Per Westermark ha scritto: > Don't you think it would help if your mail also contains the > declaration for elenco? > > /pwm > > On Mon, 12 Nov 2007, Alessandro Bugatti wrote: > > >> Hello, I wrote this method and I receive an error message in compilation: >> >> bool Dizionario::inDictionary(const string &a) const >> { >> vector<string>::iterator result = >> find( elenco.begin(), elenco.end(), a ); >> if (result == elenco.end()) return false; >> return true; >> } >> >> 598 C:\Programmi\Dev-Cpp\include\c++\3.3.1\bits\stl_iterator.h invalid >> conversion from `const std::string* const' to `std::string*' >> >> I wonder the problem is in elenco.begin() and elenco.end() and the const >> method (if I erase the keyword const the program is OK, but I don't want >> remove const because the method is const). >> Have I cast elenco.begin() and elenco.end()? In which mode? >> Thanks >> Alessandro >> >> -- >> ************************************************ >> Prof. Alessandro Bugatti >> Docente di Informatica >> Istituto Tecnico Industriale Statale B. Castelli >> E-mail: ale...@is... >> Sito web: www.imparando.net >> ************************************************ >> >> >> ------------------------------------------------------------------------- >> This SF.net email is sponsored by: Splunk Inc. >> Still grepping through log files to find problems? Stop. >> Now Search log events and configuration files using AJAX and a browser. >> Download your FREE copy of Splunk now >> http://get.splunk.com/ >> _______________________________________________ >> Dev-cpp-users mailing list >> Dev...@li... >> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm >> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users >> >> > > > > -- ************************************************ Prof. Alessandro Bugatti Docente di Informatica Istituto Tecnico Industriale Statale B. Castelli E-mail: ale...@is... Sito web: www.imparando.net ************************************************ |
From: Philip B. <phi...@pb...> - 2007-11-13 10:47:48
|
Hi Per, Thanks for all the help. You gave some great information, as always. The game is realtime, meaning that more than one thread will have to modify the enemy at the same time (the data cannot be cashed). The player thread will look for the enemies when the player walks for instance which means reading, or when he fires to see if an enemy was hit which means writing if the enemy needs to be woonded. So you think it's safe to have a critical section for each enemy? That's the way I originally planned it but I thought that maybe entering and leaving all these critical sections constantly would take up too much processor power. It's a good idea having several critical sections for each character depending on the action performed, but in this case it's not really an option because all it really does is to read and modify members in a struct. Regards Philip Bennefall ----- Original Message ----- From: "Per Westermark" <pw...@ia...> To: "Philip Bennefall" <phi...@pb...> Cc: <dev...@li...> Sent: Tuesday, November 13, 2007 3:07 AM Subject: Re: [Dev-C++] Multi threading in game > My guess is that the code you perform in an enemy is very quick (probably > microseconds) so waiting for a lock shouldn't be a problem. > > Having one big critical section is more important if you have a _huge_ > amount of objects and have to think about consumed resources. If you can, > it is better to have a granular solution, where you lock small sections. > 1) It gives less chance of a collision. > 2) It will probably be locked for a shorter time - you don't get tempted > to take a lock and then iterate through all objects and perform > mass-updates. > > There might even be situations where it might be meaningful to have more > than one lock/object. Some actions may for example only affect (or be > accted by) a limited set of object properties, while other actions may > affect (or be affected by) a different set of properties. > > A separate issue: Do all objects make their decisions based on the > "current" state, or do you make a snapshot of all state and base the next > action on the snapshot state? If everything is real-time, then it is > reasonable to walk through all objects continuously in a round-robin. If > the game is turn-based (or pseudo-realtime) then all objects decides what > will happen based on a locked state and then all objects switches to the > new state before making new decisions. In this case, you need hardly any > locking at all. Only one thread is responsible for updating each object, > and the input state is fixed until all book-keeping has been done. Then > all threads can decide to lock their huge locks, switch to next state and > then release the locks and start deciding on next state. > > About total CPU load: Need all enemies be awake? Many games can sleep all > enemies more than a specific distance from a player. What you can't see, > you can't complain about, if you excuse the pun :) > > /pwm > > On Tue, 13 Nov 2007, Philip Bennefall wrote: > >> Hello everyone, >> >> This will be a rather long message. >> >> I have a question regarding multi threading and syncrhonization for a >> game that I'm working on. The game will have hundreds of objects >> (enemies, bullets and so on), and I am trying to think of an efficient >> way to implement this using multiple threads. >> >> I will have input and player actions in one thread since they are tied >> together, window message processing in the main thread which will be >> idle for the most part, and then a thread which handles the enemies. I >> will give them different priority levels so that they don't all move at >> full speed all the time. I have two ideas for how to do this: >> >> 1. Give each enemy its own critical section object so that it is free >> whenever it is not being read or written to. Then whenever the player >> thread or another enemy in the same thread wants to access it either for >> reading or writing, it'll enter the critical section. I figure that this >> could potencially cause delays, for example what if an enemy decides to >> move while the player is firing at it and thus modifying its data from a >> different thread? >> >> 2. Have a critical section for all the enemies, which I guess would >> not be very practical but it is one idea that I had. >> >> Can anyone perhaps suggest a good way of handling this? I want to be >> able to read and write the enemy information from any thread as fast as >> possible, though most of the work will occur in one and the same thread >> (the enemy thread). >> >> Thanks in advance for any help. >> >> Regards >> Philip Bennefall > > |
From: Jonathan W. <jon...@gm...> - 2007-11-13 08:42:20
|
Nah, it's written in lemon juice, hold a candle to your screen to reveal his message :D Disclaimer: this may or may not damage your screen, proceed at your own risk. On Nov 13, 2007 7:49 AM, Chris Miller <lor...@gm...> wrote: > Either that or it's a case of some horrific packet loss ; ) > > -- > Registered Linux Addict #431495 > http://profile.xfire.com/mrstalinman > John 3:16! > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > -- <Morpheus> linux, c'est une question de VI ou de MORE |
From: Chris M. <lor...@gm...> - 2007-11-13 06:49:37
|
Either that or it's a case of some horrific packet loss ; ) -- Registered Linux Addict #431495 http://profile.xfire.com/mrstalinman John 3:16! |
From: Per W. <pw...@ia...> - 2007-11-13 02:09:00
|
It is hard to know if you want help with something, or if you wanted to inform us about something? Please expand your comments a bit ;) /pwm On Tue, 13 Nov 2007, yun peter wrote: > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
From: Per W. <pw...@ia...> - 2007-11-13 02:08:05
|
My guess is that the code you perform in an enemy is very quick (probably microseconds) so waiting for a lock shouldn't be a problem. Having one big critical section is more important if you have a _huge_ amount of objects and have to think about consumed resources. If you can, it is better to have a granular solution, where you lock small sections. 1) It gives less chance of a collision. 2) It will probably be locked for a shorter time - you don't get tempted to take a lock and then iterate through all objects and perform mass-updates. There might even be situations where it might be meaningful to have more than one lock/object. Some actions may for example only affect (or be accted by) a limited set of object properties, while other actions may affect (or be affected by) a different set of properties. A separate issue: Do all objects make their decisions based on the "current" state, or do you make a snapshot of all state and base the next action on the snapshot state? If everything is real-time, then it is reasonable to walk through all objects continuously in a round-robin. If the game is turn-based (or pseudo-realtime) then all objects decides what will happen based on a locked state and then all objects switches to the new state before making new decisions. In this case, you need hardly any locking at all. Only one thread is responsible for updating each object, and the input state is fixed until all book-keeping has been done. Then all threads can decide to lock their huge locks, switch to next state and then release the locks and start deciding on next state. About total CPU load: Need all enemies be awake? Many games can sleep all enemies more than a specific distance from a player. What you can't see, you can't complain about, if you excuse the pun :) /pwm On Tue, 13 Nov 2007, Philip Bennefall wrote: > Hello everyone, > > This will be a rather long message. > > I have a question regarding multi threading and syncrhonization for a > game that I'm working on. The game will have hundreds of objects > (enemies, bullets and so on), and I am trying to think of an efficient > way to implement this using multiple threads. > > I will have input and player actions in one thread since they are tied > together, window message processing in the main thread which will be > idle for the most part, and then a thread which handles the enemies. I > will give them different priority levels so that they don't all move at > full speed all the time. I have two ideas for how to do this: > > 1. Give each enemy its own critical section object so that it is free > whenever it is not being read or written to. Then whenever the player > thread or another enemy in the same thread wants to access it either for > reading or writing, it'll enter the critical section. I figure that this > could potencially cause delays, for example what if an enemy decides to > move while the player is firing at it and thus modifying its data from a > different thread? > > 2. Have a critical section for all the enemies, which I guess would > not be very practical but it is one idea that I had. > > Can anyone perhaps suggest a good way of handling this? I want to be > able to read and write the enemy information from any thread as fast as > possible, though most of the work will occur in one and the same thread > (the enemy thread). > > Thanks in advance for any help. > > Regards > Philip Bennefall |
From: yun p. <cer...@gm...> - 2007-11-13 02:05:58
|
From: Chris M. <lor...@gm...> - 2007-11-13 01:35:33
|
On Nov 12, 2007 5:15 PM, Philip Bennefall <phi...@pb...> wrote: > Hello everyone, > > This will be a rather long message. My resolution is 1680x1050 and it didn't even take up the whole screen :) > I have a question regarding multi threading and syncrhonization for a game > that I'm working on. The game will have hundreds of objects (enemies, > bullets and so on), and I am trying to think of an efficient way to > implement this using multiple threads. You're using pthreads, obviously. > I will have input and player actions in one thread since they are tied > together, window message processing in the main thread which will be idle > for the most part, and then a thread which handles the enemies. I will give > them different priority levels so that they don't all move at full speed all > the time. I have two ideas for how to do this: Wrong. You're looking at it from where the chair, which isn't how to write an application. What you want to do is consider which parts of the game will induce latencies. Primarily, the networking, caching, and graphics components. You're going to spend time waiting for network packets, time waiting for files from the hard drive, and for things to render. It's best to encapsulate these into their own threads so that they can do their thing with a certain degree of asynchronousness from the primary game loop. Enemies and allies are the same to the game engine. Whether one is controlled by AI simulations and one by the chimpanzee between the chair and keyboard makes little difference if you do it correctly and make sure they use the same input paths to the core game engine. > 1. Give each enemy its own critical section object so that it is free > whenever it is not being read or written to. Then whenever the player thread > or another enemy in the same thread wants to access it either for reading or > writing, it'll enter the critical section. I figure that this could > potencially cause delays, for example what if an enemy decides to move while > the player is firing at it and thus modifying its data from a different > thread? Read about pthred mutexes. > 2. Have a critical section for all the enemies, which I guess would not be > very practical but it is one idea that I had. You're thinking, but it won't work :( > Can anyone perhaps suggest a good way of handling this? I want to be able to > read and write the enemy information from any thread as fast as possible, > though most of the work will occur in one and the same thread (the enemy > thread). Speed is achieved when you ditch silly things like XML and strings to throw around core game data. Threading is used to make high latency components asynchronous from the rest of the game to make the framerate less laggy. -- Registered Linux Addict #431495 http://profile.xfire.com/mrstalinman John 3:16! |
From: Philip B. <phi...@pb...> - 2007-11-13 01:16:22
|
Hello everyone, This will be a rather long message. I have a question regarding multi threading and syncrhonization for a = game that I'm working on. The game will have hundreds of objects = (enemies, bullets and so on), and I am trying to think of an efficient = way to implement this using multiple threads. I will have input and player actions in one thread since they are tied = together, window message processing in the main thread which will be = idle for the most part, and then a thread which handles the enemies. I = will give them different priority levels so that they don't all move at = full speed all the time. I have two ideas for how to do this: 1. Give each enemy its own critical section object so that it is free = whenever it is not being read or written to. Then whenever the player = thread or another enemy in the same thread wants to access it either for = reading or writing, it'll enter the critical section. I figure that this = could potencially cause delays, for example what if an enemy decides to = move while the player is firing at it and thus modifying its data from a = different thread? 2. Have a critical section for all the enemies, which I guess would not = be very practical but it is one idea that I had. Can anyone perhaps suggest a good way of handling this? I want to be = able to read and write the enemy information from any thread as fast as = possible, though most of the work will occur in one and the same thread = (the enemy thread). Thanks in advance for any help. Regards Philip Bennefall |
From: Per W. <pw...@ia...> - 2007-11-12 23:43:15
|
Anyway, it is a common problem with C++ and const methods EMA System email: pw...@ia... Per Westermark web: http://iapetus.neab.net Vargvaegen 174B phone: +46 70 214 74 48 S-906 42 Umeaa Sweden On Tue, 13 Nov 2007, Per Westermark wrote: > Don't you think it would help if your mail also contains the > declaration for elenco? > > /pwm > > On Mon, 12 Nov 2007, Alessandro Bugatti wrote: > > > Hello, I wrote this method and I receive an error message in compilation: > > > > bool Dizionario::inDictionary(const string &a) const > > { > > vector<string>::iterator result = > > find( elenco.begin(), elenco.end(), a ); > > if (result == elenco.end()) return false; > > return true; > > } > > > > 598 C:\Programmi\Dev-Cpp\include\c++\3.3.1\bits\stl_iterator.h invalid > > conversion from `const std::string* const' to `std::string*' > > > > I wonder the problem is in elenco.begin() and elenco.end() and the const > > method (if I erase the keyword const the program is OK, but I don't want > > remove const because the method is const). > > Have I cast elenco.begin() and elenco.end()? In which mode? > > Thanks > > Alessandro > > > > -- > > ************************************************ > > Prof. Alessandro Bugatti > > Docente di Informatica > > Istituto Tecnico Industriale Statale B. Castelli > > E-mail: ale...@is... > > Sito web: www.imparando.net > > ************************************************ > > > > > > ------------------------------------------------------------------------- > > This SF.net email is sponsored by: Splunk Inc. > > Still grepping through log files to find problems? Stop. > > Now Search log events and configuration files using AJAX and a browser. > > Download your FREE copy of Splunk now >> http://get.splunk.com/ > > _______________________________________________ > > Dev-cpp-users mailing list > > Dev...@li... > > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
From: Per W. <pw...@ia...> - 2007-11-12 23:30:36
|
Don't you think it would help if your mail also contains the declaration for elenco? /pwm On Mon, 12 Nov 2007, Alessandro Bugatti wrote: > Hello, I wrote this method and I receive an error message in compilation: > > bool Dizionario::inDictionary(const string &a) const > { > vector<string>::iterator result = > find( elenco.begin(), elenco.end(), a ); > if (result == elenco.end()) return false; > return true; > } > > 598 C:\Programmi\Dev-Cpp\include\c++\3.3.1\bits\stl_iterator.h invalid > conversion from `const std::string* const' to `std::string*' > > I wonder the problem is in elenco.begin() and elenco.end() and the const > method (if I erase the keyword const the program is OK, but I don't want > remove const because the method is const). > Have I cast elenco.begin() and elenco.end()? In which mode? > Thanks > Alessandro > > -- > ************************************************ > Prof. Alessandro Bugatti > Docente di Informatica > Istituto Tecnico Industriale Statale B. Castelli > E-mail: ale...@is... > Sito web: www.imparando.net > ************************************************ > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
From: Alessandro B. <ale...@is...> - 2007-11-12 22:59:09
|
Hello, I wrote this method and I receive an error message in compilation: bool Dizionario::inDictionary(const string &a) const { vector<string>::iterator result = find( elenco.begin(), elenco.end(), a ); if (result == elenco.end()) return false; return true; } 598 C:\Programmi\Dev-Cpp\include\c++\3.3.1\bits\stl_iterator.h invalid conversion from `const std::string* const' to `std::string*' I wonder the problem is in elenco.begin() and elenco.end() and the const method (if I erase the keyword const the program is OK, but I don't want remove const because the method is const). Have I cast elenco.begin() and elenco.end()? In which mode? Thanks Alessandro -- ************************************************ Prof. Alessandro Bugatti Docente di Informatica Istituto Tecnico Industriale Statale B. Castelli E-mail: ale...@is... Sito web: www.imparando.net ************************************************ |
From: angel d. <sci...@ho...> - 2007-11-12 17:37:04
|
Is there a way i can change the windows UI (skin) to another one. Because i= got a little tire of using the old wxWigets. =20 I found another wxWigets online but it looks the same as the old wxWigets S= kin. And how can i create my own? _________________________________________________________________ Help yourself to FREE treats served up daily at the Messenger Caf=E9. Stop = by today. http://www.cafemessenger.com/info/info_sweetstuff2.html?ocid=3DTXT_TAGLM_Oc= tWLtagline= |
From: Per W. <pw...@ia...> - 2007-11-11 14:18:40
|
As you can see, the code become simler when you return the allocated array. Two things: If you fail to allocate a column, it might be a good idea to clean up any partial allocations before returning NULL. This is important if you intend to continue to run the program after a failed allocation. A 10k x 10x array of 32-bit integers would consume about 400MB, so an allocation failure could potentially leak 400MB memory. Then rename Alocate2DVect to Allocate2DVect and everything should be ok :) /pwm EMA System email: pw...@ia... Per Westermark web: http://iapetus.neab.net Vargvaegen 174B phone: +46 70 214 74 48 S-906 42 Umeaa Sweden On Sun, 11 Nov 2007, Andr=E9 Mac=E1rio Barros wrote: > My way of understand your recommendations > did result in this: > > //////code/////////// > #include <stdio.h> > #include <stdlib.h> > > int **Alocate2DVect(int lin, int col) > { > int i, **vect; > > vect =3D (int **) malloc(lin*sizeof(int)); > if(!vect) return(NULL); > for(i=3D0; i<col; i++){ > vect[i] =3D (int *) malloc(col*sizeof(int)); > if(!vect[i]) return(NULL); > } > return(vect); > } > > int main() > { > int **vector2D; > int i, j, lin=3D3, col=3D4; > > vector2D =3D Alocate2DVect(lin, col); > if(!vector2D) exit(EXIT_FAILURE); > > for(i=3D0; i<lin; i++) > for(j=3D0; j<col; j++) > vector2D[i][j] =3D i + j; > > for(i=3D0; i<lin; i++){ > for(j=3D0; j<col; j++){ > printf("%d\t", vector2D[i][j]); > } > printf("\n"); > } > > for(j=3D0; j<col; j++) > free(vector2D[col]); > free(vector2D); > > system("PAUSE"); > return 0; > } > > ///////// end of code //////// > > Is it ok? > > Thanks! > Andr=E9 > > > -----Mensagem original----- > De: Per Westermark [mailto:pw...@ia...] > Enviada em: domingo, 11 de novembro de 2007 04:27 > Para: Andr=E9 Mac=E1rio Barros > Cc: dev...@li... > Assunto: Re: [Dev-C++] function for allocate memory for 2D vectors > > > First of all - your code would be a bit simpler (you would loose one > indirection) if you modify Allocate2DVect (two l in allocate) to return > the pointer instead of taking it as a parameter. > > Second: your test if (!vect) does not check the result of the allocation, > but if you sent a pointer in to the function. > > Third: You normally don't need to release memory before ending a program, > but if you do, then your code is incorrect. You need to release all > columns before releasing the row vector. > > /pwm > > On Sun, 11 Nov 2007, Andr=E9 Mac=E1rio Barros wrote: > > > Dear Users, > > > > Could you confirm if this function is > > correct? > > The reason of my question is: inspecting > > the address of *vect in line x in the function > > is different of line y. I was expecting equal > > addresses, wasn=B4t? > > > > ////////// code ///////////////////////// > > > > int Alocate2DVect(int ***vect, int lin, int col) > > { > > int i, *pont; > > > > *vect =3D (int **) malloc(lin*sizeof(int)); // line x > > if(!vect) return(0); > > for(i=3D0; i<col; i++) *(*vect + i) =3D (int *) malloc(col*sizeof(in= t)); > > if(!vect) return(0); // line y > > return(1); > > } > > > =09> int main() > > { > > int **vector2D; > > int i, j, lin=3D3, col=3D4; > > > > if(!Alocate2DVect(&vector2D, lin, col)) exit(1); > > > > for(i=3D0; i<lin; i++) > > for(j=3D0; j<col; j++) > > vector2D[i][j] =3D i + j; > > > > for(i=3D0; i<lin; i++){ > > for(j=3D0; j<col; j++){ > > printf("%d\t", vector2D[i][j]); > > } > > printf("\n"); > > } > > > > free(vector2D); > > system("PAUSE"); > > return 0; > > } > > //////////// end of code ///////// > > > > Regards > > Andre > > > > > > No virus found in this outgoing message. > > Checked by AVG Free Edition. > > Version: 7.5.503 / Virus Database: 269.15.28/1123 - Release Date: > 10/11/2007 > > 15:47 > > > > > > -----------------------------------------------------------------------= -- > > This SF.net email is sponsored by: Splunk Inc. > > Still grepping through log files to find problems? Stop. > > Now Search log events and configuration files using AJAX and a browser. > > Download your FREE copy of Splunk now >> http://get.splunk.com/ > > _______________________________________________ > > Dev-cpp-users mailing list > > Dev...@li... > > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > No virus found in this incoming message. > Checked by AVG Free Edition. > Version: 7.5.503 / Virus Database: 269.15.28/1123 - Release Date: 10/11/2= 007 > 15:47 > > No virus found in this outgoing message. > Checked by AVG Free Edition. > Version: 7.5.503 / Virus Database: 269.15.28/1123 - Release Date: 10/11/2= 007 > 15:47 > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
From: <and...@su...> - 2007-11-11 13:51:31
|
My way of understand your recommendations did result in this: //////code/////////// #include <stdio.h> #include <stdlib.h> int **Alocate2DVect(int lin, int col) { int i, **vect; vect = (int **) malloc(lin*sizeof(int)); if(!vect) return(NULL); for(i=0; i<col; i++){ vect[i] = (int *) malloc(col*sizeof(int)); if(!vect[i]) return(NULL); } return(vect); } int main() { int **vector2D; int i, j, lin=3, col=4; vector2D = Alocate2DVect(lin, col); if(!vector2D) exit(EXIT_FAILURE); for(i=0; i<lin; i++) for(j=0; j<col; j++) vector2D[i][j] = i + j; for(i=0; i<lin; i++){ for(j=0; j<col; j++){ printf("%d\t", vector2D[i][j]); } printf("\n"); } for(j=0; j<col; j++) free(vector2D[col]); free(vector2D); system("PAUSE"); return 0; } ///////// end of code //////// Is it ok? Thanks! André -----Mensagem original----- De: Per Westermark [mailto:pw...@ia...] Enviada em: domingo, 11 de novembro de 2007 04:27 Para: André Macário Barros Cc: dev...@li... Assunto: Re: [Dev-C++] function for allocate memory for 2D vectors First of all - your code would be a bit simpler (you would loose one indirection) if you modify Allocate2DVect (two l in allocate) to return the pointer instead of taking it as a parameter. Second: your test if (!vect) does not check the result of the allocation, but if you sent a pointer in to the function. Third: You normally don't need to release memory before ending a program, but if you do, then your code is incorrect. You need to release all columns before releasing the row vector. /pwm On Sun, 11 Nov 2007, André Macário Barros wrote: > Dear Users, > > Could you confirm if this function is > correct? > The reason of my question is: inspecting > the address of *vect in line x in the function > is different of line y. I was expecting equal > addresses, wasn´t? > > ////////// code ///////////////////////// > > int Alocate2DVect(int ***vect, int lin, int col) > { > int i, *pont; > > *vect = (int **) malloc(lin*sizeof(int)); // line x > if(!vect) return(0); > for(i=0; i<col; i++) *(*vect + i) = (int *) malloc(col*sizeof(int)); > if(!vect) return(0); // line y > return(1); > } > > int main() > { > int **vector2D; > int i, j, lin=3, col=4; > > if(!Alocate2DVect(&vector2D, lin, col)) exit(1); > > for(i=0; i<lin; i++) > for(j=0; j<col; j++) > vector2D[i][j] = i + j; > > for(i=0; i<lin; i++){ > for(j=0; j<col; j++){ > printf("%d\t", vector2D[i][j]); > } > printf("\n"); > } > > free(vector2D); > system("PAUSE"); > return 0; > } > //////////// end of code ///////// > > Regards > Andre > > > No virus found in this outgoing message. > Checked by AVG Free Edition. > Version: 7.5.503 / Virus Database: 269.15.28/1123 - Release Date: 10/11/2007 > 15:47 > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.503 / Virus Database: 269.15.28/1123 - Release Date: 10/11/2007 15:47 No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.503 / Virus Database: 269.15.28/1123 - Release Date: 10/11/2007 15:47 |
From: <Ulr...@ao...> - 2007-11-11 10:18:17
|
Hi to all, I assume that the given context asks for using C and not C++. Who has to work with 2D, 3D arrays and subarrays in C on a regular basis may find the treatment of these topics in Press, Teukolsky,Vetterling,Flannery: Numerical Recipes in C, Cambridge University Press useful. Who is willing to switch to C++ is in paradise yet: #include <vector> using std::vector; int main() { int i,,j,lin=3, col=4; vector< vector<int> > vector2D(lin, vector<int>(col)); // constructor call, destruction is automatic for(i=0; i<lin; i++) for(j=0; j<col; j++) vector2D[i][j] = i + j; // what follows does not belong to the paradise I spoke about for(i=0; i<lin; i++){ for(j=0; j<col; j++){ printf("%d\t", vector2D[i][j]); } printf("\n"); } system("PAUSE"); return 0; } Regards, Ulrich |
From: Per W. <pw...@ia...> - 2007-11-11 07:26:50
|
First of all - your code would be a bit simpler (you would loose one indirection) if you modify Allocate2DVect (two l in allocate) to return the pointer instead of taking it as a parameter. Second: your test if (!vect) does not check the result of the allocation, but if you sent a pointer in to the function. Third: You normally don't need to release memory before ending a program, but if you do, then your code is incorrect. You need to release all columns before releasing the row vector. /pwm On Sun, 11 Nov 2007, Andr=E9 Mac=E1rio Barros wrote: > Dear Users, > > Could you confirm if this function is > correct? > The reason of my question is: inspecting > the address of *vect in line x in the function > is different of line y. I was expecting equal > addresses, wasn=B4t? > > ////////// code ///////////////////////// > > int Alocate2DVect(int ***vect, int lin, int col) > { > int i, *pont; > > *vect =3D (int **) malloc(lin*sizeof(int)); // line x > if(!vect) return(0); > for(i=3D0; i<col; i++) *(*vect + i) =3D (int *) malloc(col*sizeof(int)= ); > if(!vect) return(0); // line y > return(1); > } > =09> int main() > { > int **vector2D; > int i, j, lin=3D3, col=3D4; > > if(!Alocate2DVect(&vector2D, lin, col)) exit(1); > > for(i=3D0; i<lin; i++) > for(j=3D0; j<col; j++) > vector2D[i][j] =3D i + j; > > for(i=3D0; i<lin; i++){ > for(j=3D0; j<col; j++){ > printf("%d\t", vector2D[i][j]); > } > printf("\n"); > } > > free(vector2D); > system("PAUSE"); > return 0; > } > //////////// end of code ///////// > > Regards > Andre > > > No virus found in this outgoing message. > Checked by AVG Free Edition. > Version: 7.5.503 / Virus Database: 269.15.28/1123 - Release Date: 10/11/2= 007 > 15:47 > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
From: <and...@su...> - 2007-11-11 05:28:12
|
Dear Users, Could you confirm if this function is correct? The reason of my question is: inspecting the address of *vect in line x in the function is different of line y. I was expecting equal addresses, wasn´t? ////////// code ///////////////////////// int Alocate2DVect(int ***vect, int lin, int col) { int i, *pont; *vect = (int **) malloc(lin*sizeof(int)); // line x if(!vect) return(0); for(i=0; i<col; i++) *(*vect + i) = (int *) malloc(col*sizeof(int)); if(!vect) return(0); // line y return(1); } int main() { int **vector2D; int i, j, lin=3, col=4; if(!Alocate2DVect(&vector2D, lin, col)) exit(1); for(i=0; i<lin; i++) for(j=0; j<col; j++) vector2D[i][j] = i + j; for(i=0; i<lin; i++){ for(j=0; j<col; j++){ printf("%d\t", vector2D[i][j]); } printf("\n"); } free(vector2D); system("PAUSE"); return 0; } //////////// end of code ///////// Regards Andre No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.503 / Virus Database: 269.15.28/1123 - Release Date: 10/11/2007 15:47 |