« first day (468 days earlier)      last day (2381 days later) » 

9:25 AM
Hey peeps, I'm working with C++ in Unreal Engine 4, and i have an array of pointers to objects in the game, is there some way i can add these objects to the array and always retain the information about said object even after it is deleted from the level?
So i can then spawn the object again with the same data as before?

In this case it's an array of weapons, each weapon has some variables that need to be accessed, but when i destroy the object then re-instantiate said object, it spawns with all the default parameters..
 
1 message moved from Lounge<C++>
 
9:37 AM
I'll try be a little more specific, in a UE4 c++ class, i have

TArray<class AWeapon*> WeaponList;
class AWeapon* CurrentWeapon;
 
It all depends on properties of `AWeapon` and available constructors (you did not say how you spawn objects). If there are public members of `AWeapon` which provide needed information and you can pass them to your constructor - yes you can do it.
tl;dr: read documents
 
I just edited the previous message, i hit enter by accident, and now the edits don't seem to be showing up.

I have pasted the relevant code here, https://pastebin.com/qTbbSqRG

In this instance i was using TMap though. As I've not made up my mind as to which would be more appropriate to use.
 
10:03 AM
I've thought about using other methods, but the problem is that AWeapon class has multiple data types that need to be stored so i can call Destroy(), then later spawn with the same data.

The only other option i can think of is to make the meshes invisible, instead of calling destroy()?
 
I do not have any experience with UE4 and this code does not change it. I cannot guess what part of weapon state you want to preserve just by looking at that code.
 
10:19 AM
Maybe this is something API specific, i'm not quite sure how i can explain it any better.

I guess the better way to ask would be, if i add an AWeapon* to a AWeapon* array, is that data copied in memory, or are both CurrentWeapon and WeaponList[0] pointing to the same place.

It's possible WeaponList["Desert Eagle"]->GetClass() Just spawns a new object of the same class, rather than accessing the value associated with that key or index.
 
11:04 AM
I figured it out, i needed to add:
SpawnParams.Template = WeaponList["Desert Eagle"];
The newly spawned object now retains its original data using a template of the object stored in an array/map.
 
 
7 hours later…
6:22 PM
Problem: I am just starting MPI/Shared memory programming. I have a serial algorithm that I wish to make parallel. All of the "Task N" which create and enqueue "Task N+1" have been derived. There are then N task queues (About 5-6 in this case), that can be enqueued into. Each task can queue other tasks (generators) and then re-enqueue (iterating 2^N tasks); so the tasks can't simply be expanded they need to be controlled and expanded slowly so as to not overload memory.

This requires a complex message passing scheme to interact between all the nodes, but i have the exact 'messages' that ar
 
1 message moved from Lounge<C++>
 
Do I need a 'Pure C' struct implementation of vector implementation? so as to just grab a pointer and read from it? (there are N * 2^N read operations)
 
6:39 PM
Is this where shmget and other shared memory malloc / get set should be used?
1
Q: pointers and linked list with shared memory

toorI want to get 2 programs to communicate, one (server) would store datas, and the other (client) would just access it. I'll have to use a linked list to store datas because it won't stop storing, and then I was wondering if I could access to the whole linked list if only the first node is shared i...

 
7:06 PM
> All of the "Task N" which create and enqueue "Task N+1" have been derived.
I do not understand it, probably because of the lack of experience. Can you reword it?
>(iterating 2^N tasks);
Do you mean that once talking starts there are 2^N messages posted? Isn't that N^2 by a chance? (trying to guess that from context)
>i have the exact 'messages' that are all the same overarching state that can be run independently for the first 2/3 stages
How can messages be run? What is stage? Stage of what?
>I belive I don't want to serialize the data in this case
 
note that MPI is "message passing", so it's distributed memory, not shared memory
 
@roscoe_casita vector iterator is pointer itself (it does not even have bounds checking) so you definitely do not need to use pointers and you do not need own implementation as well and there is even .data() if you need a raw pointer and you can do &*vec.begin() as well.
 
7:26 PM
Why are exceptions so slow? T_T
http://coliru.stacked-crooked.com/a/584f1d979adfd125
 
1 message moved from Lounge<C++>
I never participate in this room, but allow me to inform you that your test is fucking terrible and means nothing
 
Yeah I was gonna ask if it was flawed xD (it wouldn't let me edit my reply one more time tho)
Mind explaining yourself a bit tho?
Added new test http://coliru.stacked-crooked.com/a/070340f619e91d3c
@Puppy would be nice if you could explain yourself a bit
 
7:55 PM
@Puppy
isn't that the average amount of time assumming there's no contention for the mutex / the exception is caught right away? I'm really interested in why the test is so "fucking terrible"
 
8:52 PM
I am interested as well.
 
9:46 PM
Nope. But if you get 20 rep you can start a chat room or visit an existing one like chat.stackoverflow.com/rooms/116940/c-questions-and-answerssehe 18 secs ago
brace yo selves
Hi @BloodySandwich too bad I think you need some rep points to talk (right). But, no hurry. Perhaps accepting answers helps :)
 
10:05 PM
Wow. People are generously downvoting my answer. I guess it is because they had way better advice to give. Or maybe because my answer fails to deliver on the specified "less than 1 but greater than 1000" condition :) — sehe 11 secs ago
Dumb folks everywhere. Why do we even have the site. Too many opinionated bastards, trying to deny others their entitlement, unaware of the irony.
Time for bed. Night all
 
10:19 PM
@sehe SE puts chat message date instead of comment date, funny.
 
@EuriPinhollow where - it looks like this here:
TTBOMK 23:45:56+18s == 23:46:14
 
 
1 hour later…
11:33 PM
can you do the visual basic type of expression like int answer = scanf("%d",&answer);
it always returns 0 for some reason
or 1
 
@CoderCat You can do it, but it's not doing what you (apparently) want. The return value from scanf is the number of fields it successfully converted, so you typically use it to assure that you read all the data you expected to. It doesn't tell you the value of an individual field.
 
4 messages moved from Lounge<C++>
 

« first day (468 days earlier)      last day (2381 days later) »